locked
How to Clear the values of Lookup attribute RRS feed

  • Question

  • Hi Team,

    Requirement:

    Onchange of one lookup i have to clear the values of another Lookup.

    I tried the following one

    function Lead_OnChange() {
        var lookupObject = Xrm.Page.getAttribute("lookupattribute");
        if (lookupObject != null) {
            Xrm.Page.getAttribute("lookupattribute").setValue(null);
            Xrm.Page.getAttribute("lookupattribute").DataValue = null;
            Xrm.Page.getAttribute("lookupattribute").DataValue = [];
        }

    }

    The selected lookup value of attribute is becoming null. But if i click the lookup field the values are still exist.

    The values also should get clear.

    Thanks,
    Sreenath

    Wednesday, July 30, 2014 4:45 AM

Answers

  • you can just use 

    Xrm.Page.getAttribute("lookupattribute").setValue(null);

    but if the field is read-only you need to add also this line:

    Xrm.Page.getAttribute("lookupattribute").setSubmitMode("always");
    if you want also to delete permanently the record from CRM you need to do a separate javascript REST call to delete it.


    My blog: www.crmanswers.net - Rockstar 365 Profile


    Wednesday, July 30, 2014 6:01 AM