locked
crm 4 to crm 2011 jscript conversion error RRS feed

  • Question

  •  

    Hi I have two lookups

    1. new_owercompanyid --> for account
    2. new_ownercontactid  --> contact

    **** CRM 4 jscript as below **************

    var accountLookup = crmForm.all.new_ownercompanyid;
    var contactLookup = crmForm.all.new_ownercontactid;
    accountLookup.lookuptypes = "1,2";

    accountLookup.lookuptypenames = "account:1,contact:2";

    accountLookup.lookuptypeIcons = "/_imgs/ico_16_1.gif:/_imgs/ico_16_2.gif";
    if (contactLookup.DataValue != null) {
       accountLookup.DefaultValue = contactLookup.DataValue;
       accountLookup.DataValue = contactLookup.DataValue;
       if (typeof (accountLookup.DataValue[0].data) != "undefined") {
          accountLookup.DefaultValue[0].data = accountLookup.DataValue[0].data;
       }
    }
    crmForm.all.new_ownercontactid_c.style.display = "none";
    crmForm.all.new_ownercontactid_d.style.display = "none";
    crmForm.all.new_owner_c.style.display = "none";
    crmForm.all.new_owner_d.style.display = "none";

    ******* CRM 2011 Jscript converted ***************

    var accountLookup = Xrm.Page.getAttribute("new_ownercompanyid");
    var contactLookup = Xrm.Page.getAttribute("new_ownercontactid");
    accountLookup.lookuptypes = "1,2";

    accountLookup.lookuptypenames = "account:1,contact:2";

    accountLookup.lookuptypeIcons = "/_imgs/ico_16_1.gif:/_imgs/ico_16_2.gif";
    if (contactLookup.getValue() != null) {
       accountLookup.DefaultValue = contactLookup.getValue();
       accountLookup.setValue(contactLookup.getValue());
       if (typeof (accountLookup.getValue()[0].data) != "undefined") {
          accountLookup.DefaultValue[0].data = accountLookup.getValue()[0].data;
       }
    }

    Xrm.Page.setAttributes("new_ownercontactid).setRequireLevel("none");

    ******** Error ***********

    I am getting object required error. Appreciate if you could share your thoughts.

    I am trying to creating single lookup that could allow the user to select Account as well as Contact.

     

    Monday, June 13, 2011 1:39 PM

Answers

  • By looking at your code, my guess would be the bold lines

     

    if (contactLookup.getValue() != null) {
       accountLookup.DefaultValue = contactLookup.getValue();
       accountLookup.setValue(contactLookup.getValue());
       if (typeof (accountLookup.getValue()[0].data) != "undefined") {
          accountLookup.DefaultValue[0].data = accountLookup.getValue()[0].data;
       }
    }

     

    Please try to comment out these lines and see if your problem persist.

    Now, if this solves your problem, then you will need to find a way to set up the default value for a look up, which I am also looking for a solution.  :)

     

     



    Monday, June 13, 2011 4:42 PM

All replies

  • The converting utility is developed by a community member, which doesn't guarantee 100% success of the conversion. So you will need to do a little debugging to get it working. If you can pinpoint to a particular line that is causing the problem, it should not be too hard to fix it.


    Daniel Cai | http://danielcai.blogspot.com
    Monday, June 13, 2011 3:34 PM
  • I am getting the Object required error. Appreciate if you could suggest a fix
    Monday, June 13, 2011 3:41 PM
  • By looking at your code, my guess would be the bold lines

     

    if (contactLookup.getValue() != null) {
       accountLookup.DefaultValue = contactLookup.getValue();
       accountLookup.setValue(contactLookup.getValue());
       if (typeof (accountLookup.getValue()[0].data) != "undefined") {
          accountLookup.DefaultValue[0].data = accountLookup.getValue()[0].data;
       }
    }

     

    Please try to comment out these lines and see if your problem persist.

    Now, if this solves your problem, then you will need to find a way to set up the default value for a look up, which I am also looking for a solution.  :)

     

     



    Monday, June 13, 2011 4:42 PM