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 365 | Integration, Dataverse...
Answered

Pop-up "warning" window for specific records

(0) ShareShare
ReportReport
Posted on by

Hi everyone

I've been asked if I can implement some sort of pop-up window that will contain important warning information (e.g. "DO NOT SPEAK TO THIS CONTACT!!") if someone opens a certain contact record in CRM.

Has anyone successfully done this? If so, could you please offer me some tips / a solution?

I'm guessing that the text would need to be stored in a specific field on the Contact Entity which would then be displayed in the pop-up box, but only if the text field contained data of course.

Any help would be much appreciated.

Many thanks
Jon

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello Jon,

    That should be quite easy to implement if the data is on the record.

    In order to do that you will have to write some javascript.

    Here is an example of how you can get the value from a particular field - carldesouza.com/.../

    There are multiple ways to show notification to a user:

    Xrm.Navigation.openAlertDialog - docs.microsoft.com/.../openalertdialog

    formContext.setFormNotification - docs.microsoft.com/.../setformnotification

    You will have to combine 2 of those and it will make a trick.

  • Suggested answer
    KK-365 Profile Picture
    1,010 on at

    You can write the java script for the same.

    Follow the steps mentioned in the below articles and it should be easy to implement.

    itsfascinating.com/.../

  • Suggested answer
    Leco Lv Profile Picture
    on at

    Hi partner,

       Both partners above are right. you can add an onload event to the contact table. here's the details:

       Refer link: How to add JavaScript to form on load in Dynamics 365 - Fredrik Engseth

       My example:

       pastedimage1661931585634v1.png   pastedimage1661931811185v2.png

       Save&Publish

       My  codes:

    var alertStrings = { confirmButtonLabel: "Yes", text: "DO NOT SPEAK TO THIS CONTACT!!!", title: "Sample title" };
    var alertOptions = { height: 120, width: 260 };
    Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
        function (success) {
            console.log("Alert dialog closed");
        },
        function (error) {
            console.log(error.message);
        }
    );

      result:

       pastedimage1661932790662v3.png

  • JonClay Profile Picture
    on at

    Hi there Leco Lv 

    Thanks so much for your reply.

    This seems as though it will definitely work, but I'm not sure how to show the content of a specific field instead of the text "DO NOT SPEAK TO THIS CONTACT!!".

    What I need to do is the following:

    - have a field on the Contact Entity / Contact Form called "Warning" in which I can type a string of text (e.g. "PLEASE BE CAREFUL" or "DO NOT SPEAK TO THIS CONTACT" etc.
    - most Contacts will have no text in this box as most Contacts do not require a warning to be shown on-load
    - the alert box should therefore only show on-load of the Contact if there is text in the "Warning" field

    Do you know if this is possible?

    Many thanks
    Jon

  • Suggested answer
    antc Profile Picture
    2,909 on at

    There is enough information to work it out however you will just need to add this to the code:

    var warning = formContext.getAttribute("new_warning").getValue();

    if(warning != null)

    {

      // Do the alert here..

    }

  • Suggested answer
    Leco Lv Profile Picture
    on at

    Hi partner,

        Could  you tell me what the specific conditions are, what conditions need to be met by the contact will be typed into the fields?

  • JonClay Profile Picture
    on at

    Hi Leco Lv 

    Many thanks for your reply.

    Here is what I'm trying to achieve:

    - not all contact / organisation records will need an alert box to pop up when the record is opened

    - for those that do, I would like an alert box to to pop up each time the record is opened by any user

    - I will create a new text field on the Contact Entity called Warning

    - in the Warning field I will put any text that is required in the pop up (for example. DO NOT SPEAK TO THIS PERSON!)

    - so, if text exists in the Warning field then the Contact / Organisation record should have a pop up alert box showing the contents of the Warning field

    - conversely, if the Warning field is blank then the Contact / Organisation record should not have a pop up alert box showing

    Many thanks
    Jon

  • Suggested answer
    Leco Lv Profile Picture
    on at

    Hi partner,

    Here's the details:

    pastedimage1662528161816v1.png

    function Alert(executionContext) {
        const formContext = executionContext.getFormContext();
        let cr429_alert= formContext.getAttribute("cr429_alert").getValue();
    
         if(cr429_alert == "DO NOT SPEAK TO THIS CONTACT") {
         var alertStrings = { confirmButtonLabel: "Yes", text: "DO NOT SPEAK TO THIS CONTACT!!!.", title: "!!!!!!" };
         var alertOptions = { height: 120, width: 260 };
         Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
          function (success) {
            console.log("Alert dialog closed");
        },
          function (error) {
            console.log(error.message);
        }
    );
       }
    }

  • JonClay Profile Picture
    on at

    Hi Leco Lv

    Thank you so much for sending this to me. I'm just about to fly away on holiday for a week, so I'll try this when I get back.

    Many thanks once again.

    Jon

  • JonClay Profile Picture
    on at

    Hi Leco Lv

    I'm now back from my holidays and have tested the Javascript that you sent me (thank you!).

    The process seems to work OK, but I just have a couple of queries please:

    1. I need to show whatever text is put into the alert field, so it could say anything and not just "DO NOT SPEAK TO THIS CONTACT". What do I need to change in the script in order to achieve this? I assume that I need to change the if(new_alert== part of the script.

    2. The line below this also mentions this text string, so what do I need to do in order to change that too?

    Many thanks once again,

    Jon

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 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans