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)

Notification with JS

(0) ShareShare
ReportReport
Posted on by 72

Hi everyone,
Here is my JS code

function Check () {
var i = Xrm.Page.getAttribute("new_individual").getSeletedOption();
if( i == Yes){
var message = Xrm.Page.getAttribute("parenaccountid").getValue();
var type = “please make change in”;


Xrm.Page.ui.setFormNotification(message, type);
}
}

2311.Capture1.PNG   1307.Capture2.PNG

In my form I have Individual field which one have two option "Yes" or "No"
If user choose "Yes" it should appear notification with parent account message.

But it's no matter what user choose, it's always push error with

58332.Capture.PNG

ReferenceError: Check is not defined
at eval (eval at RunHandlerInternal (salescrmdev.carsondellosa.com/.../ClientApiWrapper.aspx, <anonymous>:1:1)
at RunHandlerInternal (salescrmdev.carsondellosa.com/.../ClientApiWrapper.aspx
at RunHandlers (salescrmdev.carsondellosa.com/.../ClientApiWrapper.aspx
at ExecuteHandler (salescrmdev.carsondellosa.com/.../ClientApiWrapper.aspx
at Mscrm.TurboForm.Control.CustomScriptsManager.$Cb_1 (salescrmdev.carsondellosa.com/.../formcontrols.js
at Mscrm.TurboForm.Control.CustomScriptsManager.executeHandler (salescrmdev.carsondellosa.com/.../formcontrols.js
at Mscrm.TurboForm.Control.CustomScriptsManager.executeHandlerByDescriptor (salescrmdev.carsondellosa.com/.../formcontrols.js
at salescrmdev.carsondellosa.com/.../formcontrols.js
at salescrmdev.carsondellosa.com/.../global.ashx
at Mscrm.TurboForm.Control.Data.BooleanDataAttribute.fireOnChange (salescrmdev.carsondellosa.com/.../formcontrols.js

Please help me to resolve it, Thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    Hi ,

    I think it a Syntax Issue

    There is a space between Check and () remove it function Check() instead of function Check ()

    Thanks

    Ajyendra

    Please mark verified if answer is helpful for you.

  • Vardan  Profile Picture
    72 on at

    I removed space but still don't work

  • ajyendra Profile Picture
    1,738 on at

    Hi,

    Still get same error or something else?

    thanks

    Ajyendra Singh

  • Suggested answer
    NODAL Profile Picture
    860 on at

    Hi Vardan,

    Seems to be some syntax issue.

    Try below script.

    function Check() {

    var i = Xrm.Page.getAttribute("new_individual").getSeletedOption().text;

    if( i ==="Yes"){

    //var message = Xrm.Page.getAttribute("parenaccountid").getValue();

    var type = “please make change in”;

    Xrm.Page.ui.setFormNotification(type,"INFORMATION" );

    }

    }

    Message cannot be a lookup object.

    What message you want to display?

    Is it information or error or warning

    Regards,

    Ketan

  • Vardan  Profile Picture
    72 on at

    Hi Ketan Rajpurohit,

    Just alert for user to remember do something with parent account.

    I want to put it notification alert parent account link.

  • Verified answer
    ajyendra Profile Picture
    1,738 on at

    Hi,

    You can try

    var name = Xrm.Page.getAttribute('<FIELD_NAME>').getValue()[0].name;

    (you can also use "id":  Xrm.Page.getAttribute('<FIELD_NAME>').getValue()[0].id;)

  • Vardan  Profile Picture
    72 on at

    I do something like this

    function Check() {

    var i = Xrm.Page.getAttribute("new_individual").getSeletedOption().text;

    if( i ==="Yes"){

    var name = Xrm.Page.getAttribute('parentaccountid").getValue()[0].name;

    var type = “please make change in”;

    Xrm.Page.ui.setFormNotification(type,name,"INFORMATION" );

    }

    }

    Yes I know there is something wrong, can you help to correct?

    thanks.

  • Suggested answer
    NODAL Profile Picture
    860 on at

    Hi Vardan,

    I would recommend if you can use a simple "Business Rule" as follows.

    pastedimage1568122244671v1.png

    In Condition you can put "If Individual is Yes"

    Then show recommendation against "Parent Account".

    Regards,

    Ketan

  • ajyendra Profile Picture
    1,738 on at

    Hi,

    setFormNotification()  has wrong parameter

    docs.microsoft.com/.../setformnotification

    try this

    formContext.ui.setFormNotification(type , "INFORMATION", '1');

       // Wait for 5 seconds before clearing the notification

    window.setTimeout(function () { formContext.ui.clearFormNotification('1'); }, 5000);

  • Suggested answer
    Kalpavruksh D365 CoE Profile Picture
    2,545 on at

    Hi,

    1. Can you try to remove the space between check and bracket()?

    2. After that can you check function name you specified onChange of Individual field doesnt contain any space in the name before or after Check.

    Please refer below link:

    www.linkedin.com/.../

    3. Can you comment your JS code inside for a while and add a simple alert to make sure your function is fired.

    4. Once the function is fired, uncomment the code and correct the code as follows:

    function Check(){

       var individual = Xrm.Page.getAttribute("new_individual").getValue();

       if(individual==false){

           var type = "please make change in";

           Xrm.Page.ui.setFormNotification(type,"INFORMATION","IndiviualMessage" );

       }

       else {

           Xrm.Page.ui.clearFormNotification('IndiviualMessage');

       }

    }

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