locked
CRM 2015 OP - Clear field value using SaveChanges RRS feed

  • Question

  • Hi there,

    Anyone knows how to clear field value, eg. Address1_line1 using ServiceContext.SaveChanges() function in plugin?

    I have set the field value to string.Empty or just "" but the value remains in the field.

    However, OrganisationService.Update(entityObject) seems to work just fine.

    For example, the following does not clear the address1_line1 field value.

    	using (XrmServiceContext tmpContext = new XrmServiceContext(this.organizationService))
                {
                    Contact cont = new Contact()
                    {
                        ContactId = "xxx-xxx", //proper guid value
                        Address1_Line1 = ""
                    };
                    tmpContext.UpdateObject(cont);
                    tmpContext.SaveChanges();
                }

    But the following works:

    		Contact cont = new Contact()
                    {
                        ContactId = "xxx-xxx", //proper guid value
                        Address1_Line1 = ""
                    };
                    this.organizationService.Update(cont);
    Any idea?

    Thanks,

    Henri

    Friday, June 12, 2015 7:28 AM

All replies