web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

update null to lookup field using Xrm.WebApi.updateRecord

(0) ShareShare
ReportReport
Posted on by 235

I trying to set null to lookup field using Xrm.WebApi.updateRecord.

error:

An error occurred while validating input parameters: Microsoft.OData.ODataException: The 'odata.bind' instance or property annotation has a null value. In OData, the 'odata.bind' instance or property annotation must have a non-null string value.

code====================================================================

var updateSalesPlanMember = {};

// navigation property name
updateSalesPlanMember["kv_UserAddress@odata.bind"] = null;

Xrm.WebApi.updateRecord("kv_salesplanmember", recordId, updateSalesPlanMember).then(

function success(result) {
     ///success code
},
function (error) {
    console.error(error.message);
   }

);

code=============================================================

Thanks!

Kind regards

*This post is locked for comments

I have the same question (0)
  • Verified answer
    crm development Profile Picture
    870 on at

    Hi Santosh, refer below link..

    https://stackoverflow.com/questions/49329838/setting-null-for-single-valued-navigation-property-using-xrm-webapi

    Thanks,

    Anand

  • Suggested answer
    Nuno Profile Picture
    2,005 on at

    Hi Santosh, try

    updateSalesPlanMember["_kv_UserAddress_value"] = null;

    Hope this helps.

  • Verified answer
    David Jennaway Profile Picture
    14,065 on at

    Unfortunately this is a limitation of the webAPI. To remove lookup values, you need to send a DELETE request to delete the value from the field

  • Verified answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    Like David mentioned, you have to issue DELETE request to set null in lookup.

    var req = new XMLHttpRequest();

    req.open("DELETE", Xrm.Utility.getGlobalContext().getClientUrl() + "/api/data/v9.0/accounts()/account_parent_account()/$ref", true);

    req.setRequestHeader("Accept", "application/json");

    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    req.setRequestHeader("OData-MaxVersion", "4.0");

    req.setRequestHeader("OData-Version", "4.0");

    req.onreadystatechange = function() {

       if (this.readyState === 4) {

           req.onreadystatechange = null;

           if (this.status === 204 || this.status === 1223) {

               //Success - No Return Data - Do Something

           }

       }

    };

    req.send();

    Refer my post in Stack Overflow: [View:https://stackoverflow.com/q/49329838/7920473]

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Santosh,

    this link might be helpful, looks like you are trying to remove the reference. you may want to try with 'DELETE'.

    docs.microsoft.com/.../mt607875(v=crm.8)

    Thanks,

    Shayan

  • Verified answer
    Santosh Kulkarni Profile Picture
    235 on at

    Thanks All for the response.

    I am able to remove the reference to the lookup field.

    In my case I used below URL for DELETE request:

    xhr.open("DELETE", serverURL + "/api/data/v9.0/" + refEntity + "(" + refEnityGuid + ")/" + relationship + "(" + entityId + ")/$ref", true);

    Regards,

    Santosh

  • Suggested answer
    Salvador_Henrique Profile Picture
    5 on at

    Hello,

    I tried this and its works for me.

    var quoteid = formContext.data.entity.getId().replace('{', '').replace('}', '');
    var data = {
    "aaa_mytextfield": null,
    "_aaa_mylookupid_value": null
    }


    Xrm.WebApi.updateRecord("quote", quoteid, data).then(
      function success(result) {
         console.log(result);
      },
      function (error) {
         console.log(error)
      }
    );

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans