How do you set a null value via (SOAP) Web Services?

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

How do you set a null value via (SOAP) Web Services?

  • Comments 4
  • Likes

Assuming that Values are passed as strings via webservices we can therefore represent null as an empty string.
 
The code below is modified extract of code from the Web Services Test Harness that I use in my training classes.  If I want to set the comp_website address field to null I only need to pass in an empty string.  In the database this will be saved as a null.

ewarebase[] CRMBase;
updateresult CRMUpdateResult;
try
{
CRMBase = new ewarebase[1];
CRMCompany.companyid = int.Parse(textboxComp_Companyid.Text);
CRMCompany.companyidSpecified = true;
CRMCompany.name = textBoxComp_Name.Text;
//CRMCompany.website = textBoxComp_WebSite.Text;
CRMCompany.website = "";
CRMCompany.source = comboBox1.Text;
CRMBase[0] = CRMCompany;
CRMUpdateResult = CRM60.update("company", CRMBase);
}

 

Comments
  • How would you go about setting dates as null?

  • Please see

    dpp.sagecrm.com/.../setting-datetime-fields-to-null-via-the-soap-web-services-interface.aspx

  • Dear Jeff,

    We are working on updating selection field to null via (SOAP) Web services in Sage CRM v7.3 b.

    We have created one custom entity in Sage CRM using .Net API entity wizard and also enabled Web services for the same. We have tried above code for Text and Integer fields and found that it is working as expected. However we are trying the same for Selection fields then it does not update null value in database.

    We have even checked above code for Standard Entities like Case, Company etc. but we are getting same behavior. Initially we thought it may be an issue with patch; however we found same results in v7.2 and v7.3 with different patches.

    Any help in this regards would be appreciated.

    Sincerely,

    Dinesh

  • I've just investigated in my install (Sage CRM 7.3 sp2) and found that setting of nulls of text fields work as expected.

    In my C# project I can either receive the 'null' from the screen

    CRMCompany.website = textBoxComp_WebSite.Text;

    Or I can set the null in my code

    CRMCompany.website = "";

    Either way this results in the actual XML to be the same.

    I typically work with setting "Dropdown fields as strings in WSDL file:Yes".