How to set a user-defined list item on a Udef field (services)
This example demonstrates how to set a user-defined list item value on a user-defined field on a given contact using Net Server services.
We will be using the user-defined field Udlist one
and populate a list box with the list items for it. When an item is picked from the list box, the selected value is displayed. Clicking the Save button will set the selected value to the user-defined field Udlist one
for the contact.
The following screenshot shows how the application displays the list of values for the given user-defined field.
Populate the list box
[!code-csharpCS]
The above code segment shows how the population of the list box is done using the GetList
method of SuperOffice.CRM.Services.IMDOAgent
. This method accepts a custom list ID and returns the item array of the same:
[!code-csharpCS]
Next, we have set the MDOListItem
array as the data source for the list box:
[!code-csharpCS]
Set the user-defined field value
This section explains how the value selected on the list box is set as the user-defined field value.
[!code-csharpCS]
We have retrieved the UserDefinedFields
collection for the contact of interest. This is a dictionary that holds the user-defined field data as a key-value pair where the key string is the ProgId
of the UdefField. Thus the selected value is filled against the ProgId
of the UdefField Udlist one
as shown below.
[!code-csharpCS]
Finally, the SaveContactEntity
method is called to update the contact entity.