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)

Script Error

(0) ShareShare
ReportReport
Posted on by

Hey folks,

I hope this makes sense (since this is just outside my skill set).

When we create a new Account record via an Account Subgrid/View on the Contact form... we have some script that was dealing with clearing a field (new_contactrefferid) on the Account quick create form which was being automatically populated(cascaded?) with the Contact record.

 

Here is the script:

"if (Xrm.Page.ui.getFormType()==1)

{

Xrm.Page.getControl('new_contactreffererid').getAttribute().setValue(null);

}"

 

It was working nicely until CRM Online 2015 Update 1.

 

Here is the error that appears (Chrome):

“Script Error

One of the scripts for this record has caused an error. For more details, download the log file.
TypeError: Cannot read property 'Initialize' of undefined at eval (eval at RunHandlerInternal (thl.crm5.dynamics.com/.../ClientApiWrapper.aspx:142:32), <anonymous>:1:26”

 

And here is it's log file (Chrome):

“TypeError: Cannot read property 'Initialize' of undefined

    at eval (eval at RunHandlerInternal (thl.crm5.dynamics.com/.../ClientApiWrapper.aspx:142:32), <anonymous>:1:26)

    at RunHandlerInternal (thl.crm5.dynamics.com/.../ClientApiWrapper.aspx:142:1)

    at RunHandlers (thl.crm5.dynamics.com/.../ClientApiWrapper.aspx:101:105)

    at OnScriptTagLoaded (thl.crm5.dynamics.com/.../ClientApiWrapper.aspx:215:1)

    at thl.crm5.dynamics.com/.../ClientApiWrapper.aspx:186:1&rdquo;

 

N.B Same error occurs if we use Explorer.

Any suggestions to getting this working again are much appreciated.

 

Thanks

*This post is locked for comments

I have the same question (0)
  • Guido Preite Profile Picture
    54,086 Moderator on at

    the error doesn't look like connected to that script (assuming it's the only script you have in the form.

    However I will rewrite as

    if (Xrm.Page.ui.getFormType()==1)

    {

    Xrm.Page.getAttribute('new_contactreffererid').setValue(null);

    }

    try also to disable the script, and check if you still have the error

  • Community Member Profile Picture
    on at

    JIC, I should futher clarify that the script is called on the forms OnSave event.

    I tried disabling and there is no error but the field remains auto-populated.

    Thanks for the rewrite but also did not fix.

  • Sukh Gill Profile Picture
    967 on at

    If you use legacy form rendering does this make a difference.  Go to SETTINGS - ADMINISTRATION - SYSTEM SETTINGS.  On the general tab scroll all the way to the bottom and select yes to legacy form rendering.

    Not saying this is the fix however I have noticed switching this on causes some of the JavaScript errors to disappear and the script works fine.  I am investigating this to see why this happens.


    Sukh

  • st738407 Profile Picture
    227 on at

    We are having an almost identical issue to this, was there any resolution?

  • Suggested answer
    Hemant Kumar Sahu Profile Picture
    1,829 on at

    Hi Folks,

    Please use the null handling condition and please make sure your filed is not there in header of form.

    if (Xrm.Page.getAttribute(attributeName) != null) {

               Xrm.Page.getAttribute(attributeName).setValue(value);

           }

    Hemant

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

    If you are passing any parameter to the function then use single quote to pass the value - 'param_name'

    Without single quote CRM try to look for it and if not declared throws an exception.

    44848.Untitled.png

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