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)

Script Error

(0) ShareShare
ReportReport
Posted on by 1,799

Hi, 

New to / attempting to learn JavaScript and I've added some code to the OnChange of the Phone Field.

function warningOnChange()

{ Xrm.Page.ui.setFormNotification("Please ensure the value entered in the Phone Field is correct.", "WARNING", "1");

I'm getting a script error when the Account Form loads. I've tried enabling legacy Form Rendering but this doesn't work either. I assume I'm doing something wrong. As you can see, the code appears to have worked, as the notification is appearing in the background: 

Screen-Shot-2016_2D00_08_2D00_08-at-14.12.24.png

*This post is locked for comments

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Script Error

    Have you published changes you made?

  • JDMCRM Profile Picture
    1,799 on at
    RE: Script Error

    Hi Andrii,

    I've posted a screenshot below to ensure this is what you intended. Unfortunately I still can't get it to work (I haven't changed the code).

    Screen-Shot-2016_2D00_08_2D00_08-at-17.28.17.png

    Error Log:

    TypeError: Cannot read property 'Initialize' of undefined
    at eval (eval at RunHandlerInternal (mod387996.crm.dynamics.com/.../ClientApiWrapper.aspx), <anonymous>:1:26)
    at RunHandlerInternal (mod387996.crm.dynamics.com/.../ClientApiWrapper.aspx)
    at RunHandlers (mod387996.crm.dynamics.com/.../ClientApiWrapper.aspx)
    at mod387996.crm.dynamics.com/.../ClientApiWrapper.aspx
    at mod387996.crm.dynamics.com/.../MicrosoftAjax.js

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Script Error

    JM, in function declaration change

    warningOnChange() to warningOnChange (functiona delcaration is shown on your last screenshot).

  • Suggested answer
    sandeepc Profile Picture
    5,514 on at
    RE: Script Error

    1602.sample.PNGChange Function name to WarningAlert

  • JDMCRM Profile Picture
    1,799 on at
    RE: Script Error

    Error Log:

    TypeError: Cannot read property 'Initialize' of undefined

       at eval (eval at RunHandlerInternal (mod387996.crm.dynamics.com/.../ClientApiWrapper.aspx), <anonymous>:1:26)

       at RunHandlerInternal (mod387996.crm.dynamics.com/.../ClientApiWrapper.aspx)

       at RunHandlers (mod387996.crm.dynamics.com/.../ClientApiWrapper.aspx)

       at ExecuteHandler (mod387996.crm.dynamics.com/.../ClientApiWrapper.aspx)

       at $C7_1 (mod387996.crm.dynamics.com/.../JsProvider.ashx;ids=1223231347-405283869:8908:91)

       at executeHandler (mod387996.crm.dynamics.com/.../JsProvider.ashx;ids=1223231347-405283869:8854:18)

       at Object.<anonymous> (mod387996.crm.dynamics.com/.../JsProvider.ashx;ids=1223231347-405283869:8153:73)

       at Object.<anonymous> (mod387996.crm.dynamics.com/.../JsProvider.ashx;ids=727017229-892652631-1552783829:2:29705)

       at j (mod387996.crm.dynamics.com/.../JsProvider.ashx;ids=727017229-892652631-1552783829:2:28328)

       at Object.fireWith [as resolveWith] (mod387996.crm.dynamics.com/.../JsProvider.ashx;ids=727017229-892652631-1552783829:2:29148)

  • JDMCRM Profile Picture
    1,799 on at
    RE: Script Error

    Thanks for all the responses. I still can't get it to work. I'll send some screenshots outlining how I've got it set-up. Maybe I'm missing something.

    Screen-Shot-2016_2D00_08_2D00_08-at-16.07.28.png

    Screen-Shot-2016_2D00_08_2D00_08-at-16.07.09.png

    Screen-Shot-2016_2D00_08_2D00_08-at-16.06.57.png

    And looking from the Field Properties, rather than the Form Properties view: 

    Screen-Shot-2016_2D00_08_2D00_08-at-16.07.28.png

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Script Error

    eval problems are almost always caused by typos in function call or forgetting to add the javascript library to the form. Please check that the javascript file has been added to the account main form, and that it's using the correct file and function name.

  • Karsten Wirl Profile Picture
    4,477 on at
    RE: Script Error

    Hello.

    Please post the error log here. Thanks.

  • Shiva.B Profile Picture
    150 on at
    RE: Script Error

    Hai, I just verified you script its working for me, once recheck that you have added correct web resource

     and function name

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

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans