top of page

CRM 2015 oData Vs CRM 2016 Web API – Part 2 – Setting a Lookup Field with NULL




On the subject of CRM 2015 oData Vs CRM 2016 i will be posting the main differences that i have found when upgrading my client code to CRM 2016 Web API.


I could start with the methods (Create, Update, Retrieve,….), however, those things are easier to find in the SDK than this specific one.


Previously you could already use a method called Disassociate to set a lookup field to null, but that involves an additional call for each one of the fields to update. So, i can imagine that you would be doing something similar to:

var account = {};

account.primarycontactid = null;


XRM.Rest.Update(account, "accountSet", …,…,…);


Don’t mind with the (…) on the method call, in my case i have a generic class to expose the Odata Organization Functionalities, the point in here is how easy was to set the field to null.


Now with CRM 2016, because we have those lookups as Navigation Properties (please, see my previous post about Navigation Properties on CRM 2016 Web API), to be able to perform the same operation, we need to call the Disassociate method, in my case:

 Xrm.WebAPI.Disassociate(accountid, "accounts", "", "primarycontactid",                         SuccessCallBack,                         ErrorHandler, false);


Where the first parameter is the id of the account, the second is the type "accounts" and the forth one is the field to set up as null (remove the relation between those two entities.)

Hope it helps

0 views0 comments

Recent Posts

See All

CRM 365 On Prem – Import CRM 2016 Organization

For the last days working on testing new features of CRM 365 Online, CRM 2016/365 On Prem and few more things. And again, i had another issue, this one is really annoying, but let me explain what happ

Importing Solution in CRM 2016 Issue

Yesterday i was deploying to another environment a solution and the import was failing. The error in the log file was while importing a Process: Failure 0x80040359 The Microsoft Dynamics CRM record co

bottom of page