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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Alert Message Should be Pop-up in the centre of the screen

(0) ShareShare
ReportReport
Posted on by 55

Hi, 

I have a requirement where I need to pop-up an alert box saying "this is lead is on priority" based on condition - option set value.

I used the normal alert in Js, but the requirement was the alert box should be in centre of the page with some highlights.

Please suggest some suggestion.

Regards,

Shoaib Khan.

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

    Hello,

    Try to use Xrm.Navigation.openAlertDialog instead - docs.microsoft.com/.../openalertdialog

  • ShoaibKhan Profile Picture
    55 on at

    Hi Andrew,

    I tried to use, but the alert was prompting on the top of the page and i want it in the centre of the page.

    And I am using On premises.

    Regards,

    Shoaib Khan.

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    I have tried below on my CRM Online instance and it displays alert on center on the screen -

    var alertStrings = { confirmButtonLabel: "Yes", text: "This is an alert.", 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);

       }

    );

    CR66.PNG

    Ideally this should work on on-premise instace too. Would you be able to share image for your instance?

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Shoaib,

    Can you please provide a screenshot? Based on my experience alert window should be centered.

  • ShoaibKhan Profile Picture
    55 on at

    Hi,

    Thanks for your Help...But It's still showing errors.

    Here is my code :--

    function PopupifsourceCSmnm()

    {

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

    {

    var Source = Xrm.Page.getAttribute("ccs_source").getValue();

    if(Source == 10)

    {

    var alertStrings = { confirmButtonLabel: "Ok", text: "This is high profile customer lead. Please handle it carefully.", title: "Message" };

    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);

      }

    );

    }

    }

    }

    And here is the Error prompting on my screen.

    pastedimage1642664306038v5.png

  • Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    I have modified your code check null condition and also added some alert in your code. Please copy below code and try.

    function PopupifsourceCSmnm()

    {

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

    {

    alert("Form Type is 2");

    if(Xrm.Page.getAttribute("ccs_source")!=null && Xrm.Page.getAttribute("ccs_source")!=undefined)

    {

    var Source = Xrm.Page.getAttribute("ccs_source").getValue();

    alert("Source Value:"+Source);

    if(Source == 10)

    {

    var alertStrings = { confirmButtonLabel: "Ok", text: "This is high profile customer lead. Please handle it carefully.", title: "Message" };

    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);

    }

    );

    }

    }

    }

    }

    Sorry I couldn't able to insert code with proper format.

    Make sure you have mentioned correct function name in form event handler, also check if your javascript has any synatx error on below site.

    https://esprima.org/demo/validate.html


    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • ShoaibKhan Profile Picture
    55 on at

    Hi Bipin,

    Thanks for your support, but alerts are showing, and then after alerts, the error above mentioned pops-up

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    Error message 'undefined' is really not helping.

    If you could send your entire javascript code on your Entity then I should be able to help.

    Check if you have added all the fields which you are using in your JS code is present on form, also make sure you check if control is not returning null before getting value from any field - check my previous post.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at

    Hi,

    Did you tried this approach to solve the problem?

    static void JobBoxDemo(Args _args)
        {
            DialogButton diagBut;
            str strMessage = "The No button should have initial focus.";
            str strTitle = "Title";
            ;
            diagBut = Box::yesNoCancel(
                strMessage,
                DialogButton::No, // Initial focus is on the No button.
                strTitle);
            if (diagBut == DialogButton::No)
                {
                    print "The No button was clicked.";
                }
            else
                {
                    print "The button that was clicked was: ", diagBut;
                }
            pause;
        }

  • Inogic Profile Picture
    682 on at
    Hi Shoaib,
    For your requirement, I suggest you explore Alerts4Dynamics, a productivity app for Dynamics 365 CRM by Inogic. It provides a more flexible and powerful way to manage and display alerts directly within CRM. 
    With Alerts4Dynamics, you can create Pop-up alerts that appear directly on the record form in CRM, meeting your requirement for displaying an alert message on the screen. These alerts can be categorized based on priority levels such as Information, Warning, or Critical, ensuring that users can easily prioritize them. Additionally, the app supports various types of alerts, including Rule-based and Record-based alerts, allowing you to trigger notifications based on your specific conditions.
    Some of the key benefits of Alerts4Dynamics include:
    •    Alert Modes: You can configure the alert to be displayed as Pop-ups, Form Notifications (Dialog & Bar), or even Email Notifications, allowing you to choose the most effective communication mode.
    •    Multiple Alert Types: Create various types of alerts (Announcement, Rule-based, Record-based, Event-based) based on your needs.
    •    Alert Levels: You can assign different priority levels to alerts, such as Information, Warning, or Critical, to ensure your team prioritizes them appropriately.
    •    Multi-language Support: Alerts can be created in multiple languages, enhancing communication within diverse teams.
    •    View Logs: Track read/dismissed notifications for better accountability.
    •    Email Digest Workflow: Automatically receive/send notifications via email on a Daily, Weekly, and Monthly basis.
    •    Post Notification: Compose and deliver custom post messages as notifications to users by tagging them directly from the CRM record form.
    This app can streamline your alert management process and provide a more customizable and visually appealing solution compared to the traditional JavaScript alerts.
    Hope this helps!
    For more information or assistance with managing alerts and notifications in your CRM, please contact us at  crm@inogic.com..
    If you are interested in testing the solution for your needs, then you should consider checking out our app for a 15-day free trial from our website or Microsoft AppSource.
     
    Thanks,
    Sam
    Website: www.inogic.com

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 61

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans