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)

Setting Notification

(0) ShareShare
ReportReport
Posted on by 123

Hi 

Hope someone can help. I seem to be going round in circles

I have created a web resource file with the following JavaScript.


function setConsentPreferenceNotification() {

var consentpreferencegiven = Xrm.Page.getAttribute("acg_consentpreferencegiven").getValue();

if (consentpreferencegiven == "805270001") {

Xrm.Page.ui.setFormNotification("YOu must get Consent", "INFO", "805270001");

}

else {

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

}

}

 


Ive created a field Yes/No options set and named it ConsentPreferenceGiven. Set default value to NO.

Then went to form properties and added this form to Form Libraries and Event Handler (named function to ConsentPreferenceNotification)

But i keep getting an error. 

Have i missed out a step or written the code wrong?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Setting Notification

    Hi Damesh ,

    You are saying that you created Yes/No options , is this two options field or optionset?

    Seems your code is fine you can debug and check whether your code else part executing. 

    Also try with this - 

    function setConsentPreferenceNotification() {
        var consentpreferencegiven = Xrm.Page.getAttribute("acg_consentpreferencegiven").getValue();
        if (consentpreferencegiven == "805270001") {
            Xrm.Page.ui.setFormNotification("YOu must get Consent", "INFO", 123);
        }
        else {
            Xrm.Page.ui.clearFormNotification(123);
        }
    }


    You can also try with field notification-

    function setConsentPreferenceNotification() {
        var consentpreferencegiven = Xrm.Page.getAttribute("acg_consentpreferencegiven").getValue();
        if (consentpreferencegiven == "805270001") {
            Xrm.Page.getControl("acg_consentpreferencegiven").setNotification("YOu must get Consent", "INFO");  
        }
        else {
            Xrm.Page.getControl("acg_consentpreferencegiven").clearNotification();
        }
    }


    Hope this helps .

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: Setting Notification

    Hello,

    Your code seems fine just your using wrong value while clearning, you can try to debug and see where it's failing

    function setConsentPreferenceNotification() {

    var consentpreferencegiven = Xrm.Page.getAttribute("acg_consentpreferencegiven").getValue();

    if (consentpreferencegiven == "805270001") {

    Xrm.Page.ui.setFormNotification("YOu must get Consent", "INFO", "805270001");

    }

    else {

    Xrm.Page.ui.clearFormNotification("805270001");

    }

    }

  • Damesh Peri Profile Picture
    123 on at
    RE: Setting Notification

    Thanks Guys. My silly mistake.

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