locked
Lead conversion to Opportunity - onload code does not run RRS feed

  • Question

  • I have jscript that loads a field value when the opportunity form is created (FormType ==1).  However, when using the our of box Lead Qualify function, the Opportunity code does not run.  Any ideas on why and how to fix?

    function ElectricMargin_oncreate()
    {
    var EM = Xrm.Page.getAttribute("esui_electricmargin");
    var FormType = Xrm.Page.ui.getFormType();

    if(FormType == 1)
       { 
          EM.setValue(0.0015);
       }
    }


    Ken Compter

    Friday, August 9, 2013 2:37 PM

Answers

  • This is because when you go through the lead qualify process, the opportunity gets created in the background and the record that opens is then considered an existing record FormType = 2.

    Need to adjust your logic to check for FormType 2 and then perform the logic if the field you are trying to set contains a null value.


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn


    Friday, August 9, 2013 3:12 PM
    Moderator

All replies

  • This is because when you go through the lead qualify process, the opportunity gets created in the background and the record that opens is then considered an existing record FormType = 2.

    Need to adjust your logic to check for FormType 2 and then perform the logic if the field you are trying to set contains a null value.


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn


    Friday, August 9, 2013 3:12 PM
    Moderator
  • Jason, right on target as always, thanks for the help


    Ken Compter

    Friday, August 9, 2013 3:22 PM