locked
crm 4.0 - Set stringproperty to null/blank using the SDK service RRS feed

  • Question

  • HI,

    I am using CRM 4.0 on premise version. I have one attribute of type string. I need to set its value blank/null using sdk service. I am using following code to set value in attribute of  string type. But it gives me error while calling service.Update method.

    StringProperty strPrpstring = new StringProperty("new_test", string.Empty);

    deUpdatedData.Properties["new_test"] = strPrpstring;

    service.Update(deUpdatedData);

    • Edited by Ravi MRC Thursday, July 18, 2013 10:44 AM formatting
    Thursday, July 18, 2013 10:43 AM

Answers

  • Thanks for reply Zarko. IsNull property is not available for String attributes. It's for CRMBoolean, CRMMoney, etc. I have done this by removing and adding attribute again. It's working now.

    if (deUpdatedData.Properties.Contains("new_test"))

    {

    deUpdatedData.Properties.Remove("new_test");

    }

    StringProperty strPrpTest = new StringProperty("new_test", string.Empty);

    deUpdatedData.Properties.Add(strPrpTest);service.Update(deUpdatedData);



    • Edited by Ravi MRC Thursday, July 18, 2013 11:46 AM formating
    • Marked as answer by Ravi MRC Thursday, July 18, 2013 12:21 PM
    Thursday, July 18, 2013 11:45 AM

All replies

  • Try setting the IsNull property to True. I would try deUpdatedData.Properties["new_test"].IsNull = true;

    Zarko

    Thursday, July 18, 2013 11:17 AM
  • Thanks for reply Zarko. IsNull property is not available for String attributes. It's for CRMBoolean, CRMMoney, etc. I have done this by removing and adding attribute again. It's working now.

    if (deUpdatedData.Properties.Contains("new_test"))

    {

    deUpdatedData.Properties.Remove("new_test");

    }

    StringProperty strPrpTest = new StringProperty("new_test", string.Empty);

    deUpdatedData.Properties.Add(strPrpTest);service.Update(deUpdatedData);



    • Edited by Ravi MRC Thursday, July 18, 2013 11:46 AM formating
    • Marked as answer by Ravi MRC Thursday, July 18, 2013 12:21 PM
    Thursday, July 18, 2013 11:45 AM