Dropdown field settings in SOAP Web Services

1 minute read time.

In Sage CRM you can control whether dropdown fields are handled as enumerators or as strings in code.

This is an important setting of which to be aware when creating your code.

I started a project this week and failed to realise that I had changed the setting in Sage CRM after I had added the WSDL reference into my project.

I had written the code below:

[code language="csharp"]
address newAddress = new address();
newAddress.address1 = "1 Main Road";
newAddress.city = "London";
newAddress.country = addr_country.UnitedKingdom;
[/code]

The code was part of a longer program that added a new person and new address into Sage CRM.

The address was added to the 'Person' class and then sent to Sage CRM.

[code language="csharp"]
newPerson.address.records[0] = newAddress;
addresult CRMAddResult = CRMService.add("person", CRMBase);
[/code]

When the code ran, there was no error shown and the address was added along with the new person. BUT the selection value was blank. The country value was ignored.

What I had failed to realise was that my code was using a WSDL version in which the address was described as an local enumerator.

The actual current WSDL handled the country selection in the address table as a string.

To solve my issue I refreshed the web reference in my project.

and then changed my code to read

[code language="csharp"]
address newAddress = new address();
newAddress.address1 = "1 Main Road";
newAddress.city = "London";
newAddress.country = "UK";
[/code]

The moral of the story is that you should always check your code matches the current WSDL version in Sage CRM.