web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Unable to get property 'setAttribute' of undefined or null reference

(0) ShareShare
ReportReport
Posted on by 1,821

Hi,

I upgraded CRM 2015 to CRM 2016 by Migrate method - import organization.  Upgrade organization was completed successfully.   But when I select opportunity I got error.  When I debug java script I found it is coming from below script when  load opportunity main form.  This script is using to set the lookup filed of property of parent account in opportunity always to accounts. so the contact will not be selected. 

crm-2016-2.png

Please help me to solve below script which is not working in CRM 2016.   Kindly let me know is there any custom validation tool or legacy check tool before upgrading CRM 2016 or check in CRM 2015.

Error

document.getElementById("customerid").setAttribute("lookuptypes", "1");

crm-2016-1.png

TypeError: Unable to get property 'setAttribute' of undefined or null reference

   at Form_onload (testcrm2016/.../Opportunity_main_library.js)

   at eval code (eval code:1:1)

   at RunHandlerInternal (testcrm2016/.../ClientApiWrapper.aspx)

   at RunHandlers (testcrm2016/.../ClientApiWrapper.aspx)

   at OnScriptTagLoaded (testcrm2016/.../ClientApiWrapper.aspx)

   at Anonymous function (http://testcrm2016/SSC/form/ClientApiWrapper.aspx?ver=-1632125718:199:1)

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    jlattimer Profile Picture
    24,562 on at

    You might check out this blog post on using addPreFilter to a lookup to limit the selection to only Accounts. Users will be able to switch to Contacts in the drop down, but no records will be displayed to pick from.

    http://www.powerobjects.com/2015/11/20/restrict-customer-lookup-to-accounts-or-contacts-in-dynamics-crm/

  • Suggested answer
    Dynamics_Alok Profile Picture
    1,746 on at

    If you have OOB addPreSearch method ,please dont go for unsupported way.

    You are getting error because document.getElementById("customerid") is not returning Control object and hence you dont have setAttribute method.

    You can do what you want to using addPreSearch.

  • Suggested answer
    Zohaib Uddin Khan Profile Picture
    2,822 on at
    1. Check out Microsoft Dynamics CRM 2015 Custom Code Validation Tool (Even this tool is only for CRM 2015, but still it will help/guide you).
    2. For filtering of records for Customer lookup in Opportunity, use addPreSearch and addCustomFilter. In this way, you will achieve your goal.

    Thanks.

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Noushad,

    Try using the following codes.

    window.parent.document.getElementById("customerid").setAttribute("lookuptypes", "1");

                                                                                    OR

    var lookupData = Xrm.Page.getAttribute('customerid').getLookupDataAttribute();
     
    //check if multiple type dropdowns enabled for this lookup and it is not a partylist. For partylist we might want to select an account and a contact
    if (lookupData.getSupportedLookupTypes().length > 1
         && !lookupData.getIsPartyList()
         && lookupData.getSingleLookupTypeId() !== 2) {
        lookupData.setLookupTypes(['contact'])
    }

    See: https://dreamingincrm.com/2016/06/02/restricting-the-customer-lookup/

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans