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.

Parents
  • For partners who may be switching between customer projects or between on-premise and cloud versions, having the wrong web reference can be lead to errors like the one I received today using queryRecord(), "Instance validation error: '5M - 10M' is not a valid value for comp_revenue." The code was working in my on-premise test and then I changed the web service url and logon to point to the cloud version and the error appeared. After chasing this as a selection field error, I switched out the web reference to be the cloud web reference, and all working now.

Comment
  • For partners who may be switching between customer projects or between on-premise and cloud versions, having the wrong web reference can be lead to errors like the one I received today using queryRecord(), "Instance validation error: '5M - 10M' is not a valid value for comp_revenue." The code was working in my on-premise test and then I changed the web service url and logon to point to the cloud version and the error appeared. After chasing this as a selection field error, I switched out the web reference to be the cloud web reference, and all working now.

Children
No Data