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)

CRM - Confirm DIalog ( OK / CANCEL ) pop-up again after i click Cancel option

(0) ShareShare
ReportReport
Posted on by 152

Hello everyone,

I created a simple javaScript which throw a Confirm Dialog which fire on change the value of a pick list field.

When I execute it, the confirm dialog appears and if i click cancel it appears 2 more times until finally it performs the action required.

How can i fix it and ensure that it only appears once?

Kind regards,

below you can see my code

function ConfirmationDialog(){
var ValueSelected = Xrm.Page.getAttribute('gri_sustainabilityreportstatus').getValue();
debugger;
if (ValueSelected == 172340000 || ValueSelected == 172340001 || ValueSelected == 172340003){

Xrm.Utility.confirmDialog("This option will send a email.", function(){
// Callback that happens when user clicks OK
return;
}, function(){
// Callback that happens when user clicks Cancel.
Xrm.Page.getAttribute('gri_sustainabilityreportstatus').setValue(null);
return;
});
}
else{
return;
}
}

*This post is locked for comments

I have the same question (0)
  • Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    This is because, you are changing  the value for the attribute gri_sustainabilityreportstatus, in the Cancel callback function.

    Please check the value of the optionset second time, when you set null

  • Jorge Gomez Profile Picture
    152 on at

    Yes i know it, that is the functionality desired.

    But it took 3 loops to set it. What i mean is:

    Select value 1

    pop-up dialog ( the value is 1)

    click cancel

    pop-up dialog ( the value is still 1)

    click cancel

    pop-up dialog( the value is still 1)

    click cancel

    the value switch to null, the pop-up dialog does not appear anymore.

  • Verified answer
    ashlega Profile Picture
    34,477 on at

    Try moving your code to the setTimeout like this - worked for me:

    function ConfirmationDialog(){

    setTimeout(function()

    {

     <YOUR CODE HERE>

    }, 10);

    }

    The problem is that you are changing that value inside "onchange" handler, so onchange fires again, however, since it's all happening synchronously, when you call "getValue" it's still giving you some value (not null yet). Eventually, it gets through.. but it seems to require a few cycles.

  • Jorge Gomez Profile Picture
    152 on at

    Thank you very much Alex!

    It works correctly now!

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