locked
lookup fields not being reset at null in an opportunity - CRM 2013 Online RRS feed

  • Question

  • Hi,

    I have an opportunity form where I have several lookups to the account entity. When working on CRM 2011 I had the following function working fine and it does not work after migration on CRM 2013 Online :

    function opportunity_init_values() {

        if (Xrm.Page.ui.getFormType() == XXX.Common.FormTypeEnum.FORM_TYPE_CREATE) {

            var XXX_insurance_attr                = Xrm.Page.getAttribute("XXX_insurance");

            var XXX_insuranceexpertoffice_attr    = Xrm.Page.getAttribute("XXX_insuranceexpertoffice");

            var XXX_otherexpertoffice_attr        = Xrm.Page.getAttribute("XXX_otherexpertoffice");

            var XXX_insuredexpertoffice_attr      = Xrm.Page.getAttribute("XXX_insuredexpertoffice");

            if (XXX_insurance_attr != null)               { XXX_insurance_attr.setValue(null); }

            if (XXX_insuranceexpertoffice_attr != null)   { XXX_insuranceexpertoffice_attr.setValue(null); }

            if (XXX_otherexpertoffice_attr != null)       { XXX_otherexpertoffice_attr.setValue(null); }

            if (XXX_insuredexpertoffice_attr != null)     { XXX_insuredexpertoffice_attr.setValue(null); }

        }

    }

    The fields are no more set to null when I create an opportunity from an account. I get the account name as default value in the other fields which I do not want.

    Any help ?

    Monday, February 10, 2014 10:09 AM

Answers

  • Finaly soved my problem. The code was correct. It was just that when creating an opportunity from an account the system (CRM 2013) used by default the Quick Form which did not support/run my script. I just deactivated thie Qick Form functionality from my opportunity entity and solved my problem.

    Than you again Jason for trying.

    • Marked as answer by yodo94 Wednesday, February 12, 2014 11:40 AM
    Wednesday, February 12, 2014 11:39 AM

All replies

  • What if you try something like

    Xrm.Page.data.entity.attributes.get("XXX_insurance_attr").setValue(null);


    Jason Peterson

    Monday, February 10, 2014 11:32 AM
  • Hi Jason,

    Thank you for your answer. I shall try it right away but could you explain why this should work ? Is it documented somewhere you would know. I am trying to understand.

    Best regards.

    Youcef

    Monday, February 10, 2014 12:45 PM
  • Hi Jason,

    Just tried your solution but still same effect. Thank you anyway.

    Youcef

    Monday, February 10, 2014 12:56 PM
  • Finaly soved my problem. The code was correct. It was just that when creating an opportunity from an account the system (CRM 2013) used by default the Quick Form which did not support/run my script. I just deactivated thie Qick Form functionality from my opportunity entity and solved my problem.

    Than you again Jason for trying.

    • Marked as answer by yodo94 Wednesday, February 12, 2014 11:40 AM
    Wednesday, February 12, 2014 11:39 AM