locked
Clear Lookup on Load - JavaScript RRS feed

  • Question

  • Hi

    I am trying to clear two lookup field values when a new form is loaded.

    I have used the following script:

    function SetLookupsNull {
    if (Xrm.Page.ui.getFormType() == 1) {
            Xrm.Page.getAttribute(new_contactlookup).setValue(null);
            Xrm.Page.getAttribute(new_patientlookup).setValue(null);
    }

    I receive an error 'Object not supported'

    Would someone please assist?
    Tony

    Thanks

    Thursday, July 9, 2015 7:59 AM

Answers

  • Seems like your missing the quotation marks around the names of the fields.

    Try this.

    function SetLookupsNull {
    if (Xrm.Page.ui.getFormType() == 1) {
            Xrm.Page.getAttribute("new_contactlookup").setValue(null);
            Xrm.Page.getAttribute("new_patientlookup").setValue(null);
    }


    Halldór Jóhannsson


    Thursday, July 9, 2015 9:38 AM