Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

cancel button on change task

harry24
Tera Contributor

Hello 

I want to create cancel button on change task which will cancel the change task .

It should make worknote field mandatory and add pop up whenever user tries to cancel the change task 

6 REPLIES 6

Nisha15
Mega Sage
Mega Sage

Hi @harry24 
create a client callable ui action
onclick call the function name:openConfirmationDialog()
use the below code:

function openConfirmationDialog() {
    var gm = new GlideModal("glide_confirm_standard", true, 600);
    gm.setTitle("Test title");
    gm.setPreference("title", "Test body text");
    gm.setPreference("warning", "false");
    gm.setPreference("onPromptComplete", function() {
        g_form.setMandatory('work_notes', true);
    });
    gm.setPreference("onPromptCancel", function() {
        alert("You clicked on 'Cancel'");
    });
    gm.render();
}

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @harry24 

 

Why you need a button, we have OOTB cancel value in state and use that to do your work. 

 

AGLearnNGrow_0-1714390963042.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************