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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Upgraded from CRM 4.0 to 2016 (on-prem) ... now get script errors in Contacts

(0) ShareShare
ReportReport
Posted on by 35

Particularly in Contacts ... when in "CONTACT" 'view' things seem to be okay, but when changing to "CONTACT:Information" in any contact, the script errors start (even when just changing to this view).

Script Error

One of the scripts for this record has caused an error. For more details, download the log file.
ReferenceError: 'crmForm' is undefined at Form_onload (crm2016.domain.local/.../Contact_main_library.js)

Click OK. All good. Changes can be made to contacts, and mostly there are no issues. Create a new contact, and get the same script error again. Switch from CONTACT to CONTACT:Information view ... and script error appears.

The downloaded log file contains:

ReferenceError: 'crmForm' is undefined
at Form_onload (crm2016.domain.local/.../Contact_main_library.js)
at eval code (eval code:1:1)
at RunHandlerInternal (crm2016.domain.local/.../ClientApiWrapper.aspx)
at RunHandlers (crm2016.domain.local/.../ClientApiWrapper.aspx)
at OnScriptTagLoaded (crm2016.domain.local/.../ClientApiWrapper.aspx)
at Anonymous function (crm2016.domain.local/.../ClientApiWrapper.aspx)

Thanks,

Jason

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Upgraded from CRM 4.0 to 2016 (on-prem) ... now get script errors in Contacts

    Hi ,

    The error says  "crmForm" reference is missing here in the webresource Contact_main_library.js .

    You need to investigate  where and which JS library  "crmForm" has been declared load particular JS library in the  top order before load  Contact_main_library.js .

     

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at
    RE: Upgraded from CRM 4.0 to 2016 (on-prem) ... now get script errors in Contacts

    Go to "customizations", navigate to Contact entity, open the "Contact: Information" form editor, click Form properties.

    Verify the script files starting with "Contact_main_library.js" & "Form_onload" method. There may be a broken dependency from a different file or "crmForm" variable issue in this file.

    Cross check if you have a backup 4.0 instance for this file. Check the content & paste here if you need more assistance.

    You can also debug & see the issue.

  • Jay26Cee Profile Picture
    35 on at
    RE: Upgraded from CRM 4.0 to 2016 (on-prem) ... now get script errors in Contacts

    Hi ... apologies for the delay, too much on my plate!

    Firstly, I should probably point out that I am pretty new to CRM. my knowledge comes from upgrading an inherited 4.0 environment to 2016 (on prem). This was a painstaking process in itself!!

    I have edited the Form propoerties and it is showing the following in the Form Library Contact_main_library.js...

    function IFRAME_PNetwork_onload()
    {

    }
    function Form_onload()
    {
    // Load Network site URL
    {
    var SocialURL = crmForm.all.new_profnetworkpage.DataValue;
    if (SocialURL != null)
    {
    crmForm.all.IFRAME_PNetwork.src = SocialURL;
    }
    }
    }

    Is there a syntax issue, something migrate incorrectly with CRM coming up through the versions to 2016, etc.?

    Thanks.

    Jason

  • Jay26Cee Profile Picture
    35 on at
    RE: Upgraded from CRM 4.0 to 2016 (on-prem) ... now get script errors in Contacts

    Hi ... again, apologies for the delay.

    In Customizations, I only have Contact entity. If I expand that, there is no form called Contact : Information. The only one I can see that might be relevant is "Information" which is a Main form type (Active, Managed, and is customizable). Weirdly, the version shows as 1.0. If I open this form, and then perform Form Properties ... I can see that the Contact_main_library.js is listed in the Form Libraries [editing it shows the contents as pasted in the previous response in this thread]. Event Handlers shows Control: Form ... Event: Onload and the library above as listed. It is enabled with the Function set to "Form_onload".  There are no listed Dependent Fields enabled.

    What is crmForm? If this a library in the form of a file that did not migrate from 4.0? Or is it just a reference? Something part of CRM by default or a custom name?

    Thanks.

    Jason

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at
    RE: Upgraded from CRM 4.0 to 2016 (on-prem) ... now get script errors in Contacts

    Yes, those CRM 4.0 syntax were deprecated & replace with with "Xrm.Page.getAttribute".

    var SocialURL = Xrm.Page.getAttribute("new_profnetworkpage").getValue();

    Xrm.Page.getControl('IFRAME_PNetwork').setSrc(SocialURL);

    community.dynamics.com/.../112699

  • Suggested answer
    Shidin Haridas Profile Picture
    3,497 on at
    RE: Upgraded from CRM 4.0 to 2016 (on-prem) ... now get script errors in Contacts

    crmForm (used in v4.0) was the older equivalent of Xrm.Page, which is also getting depreciated now!

    Easiest way for you to find out all the legacy JavaScript code would be to use the 'Dynamics 365 v9 Javascript Validator' tool from the XrmToolbox

    This will scan all your custom script files and notify you of all the deprecated methods.

    Cheers,

    Shidin

    If my answer helps you, please mark it as verified.

  • Jay26Cee Profile Picture
    35 on at
    RE: Upgraded from CRM 4.0 to 2016 (on-prem) ... now get script errors in Contacts

    Thanks Shidin for you response. I have managed to get XrmToolBox up and running, installed the plugin you suggested.

    The Retrieve JScript Webresources ... Found 5 JScript Webresources.

    The Scan to validate resulted in 0 (zero) issues.

    I am going to take a look at Arun's suggestion above ... but I am starting to delve into some uncharted territory with these scripts!

  • Jay26Cee Profile Picture
    35 on at
    RE: Upgraded from CRM 4.0 to 2016 (on-prem) ... now get script errors in Contacts

    Hi Arun,

    Can you offer some guidance on how to make the changes?

    Do these changes require special tools to make the changes?

    I'd like to know whether your recommendation is that if this is not something one has done before, then should it be left to the 'professionals' or is it simple enough with some guidance from someone like yourself?

    I ask I the link you provide seems to shed light on someone else's issue, but I am still lost as to where this change is applied - and how.

    Thanks.

    Jason

  • Verified answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at
    RE: Upgraded from CRM 4.0 to 2016 (on-prem) ... now get script errors in Contacts

    Not really. You can do it yourself. Pls follow the below guide to make changes to js web resource from form editor.

    [View:https://dynamicscrmpros.com/getting-started-with-javascript-form-scripting-for-microsoft-dynamics-crm-2011/:750:50]

    Look for your existing js file, edit it in browser (take a backup if you want) or copy the content to favorite text editor like Notepad++

    Replace the below lines

    var SocialURL = crmForm.all.new_profnetworkpage.DataValue;
    
    if (SocialURL != null)
    
    {
    
    crmForm.all.IFRAME_PNetwork.src = SocialURL;
    
    }

    with these lines:

    var socialURL = Xrm.Page.getAttribute("new_profnetworkpage").getValue();
    
    if (socialURL != null)
    
    {
    
    Xrm.Page.getControl('IFRAME_PNetwork').setSrc(socialURL);
    
    }
    

  • Jay26Cee Profile Picture
    35 on at
    RE: Upgraded from CRM 4.0 to 2016 (on-prem) ... now get script errors in Contacts

    Hi,

    The changes suggested to the script had no effect.

    Looking into this a little more has made me even more confused ... for 2 reasons:

    1. When I edited the 'script' called Contact_main_library.js via the Form Editor in CRM, I still got the same error. This implies that the issue is not with that edited change as there is no longer a reference to "crmForm" yet the error message still references this.

    Also, I tried to look for Contact_main_library.js as a script file on the server, but none were found. The closest was a script file called Contact_main_system_library.js ... and editing this script had no reference to "crmForm"!

    I searched on the server for ALL .js script files starting with "Contract" and none have a reference to "crmForm".

    2. The other confusing this is that the default Contact form that loads when you click on "New Contact" loads a form called "Contact" which is a Main form type. Looking at the Form properties for this reveals no Form Libraries and no Event Handlers being referenced. This probably explains why this Contact form does not generate any script errors.

    It is only when you click on the CONTACT drop-down and select the form called "Information" to load that form up does the error appear. And, it is that form - called "Information" and also a Main form type - that has the Form Library and Event Handler called Contact_main_library.js.

    So, I guess my question here is ...... what is this script and why is it needed?

    Regards,

    Jason

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans