How to add confirmation message before deleting change request record

Pratiksha2
Mega Sage

Hello,

 

I have created separate delete UI action for change request table to prevent deletion of change request if it has any open change tasks.

Now, I want to show confirmation message before deleting change request.

Can anyone help me to achieve this?

 

Please check my code below:

var id = current.sys_id;
var FinalUrl2 = new checkOpenChangetasks();
 var result2 = FinalUrl2.openChangetasks1(id);

if (result2 == true) {
 gs.addErrorMessage('Please delete change task(s) prior to deletion of the change request');
 action.setRedirectURL(current);

 } else {
 var tasks = new GlideRecord("change_task");
tasks.addQuery("change_request", current.sys_id);
 tasks.query();

 while (tasks.next()) {
tasks.deleteMultiple();
 }

current.setWorkflow(false);
current.deleteRecord();
 action.setRedirectURL(current);
}

 

4 REPLIES 4

Mohith Devatte
Tera Sage
Tera Sage

hello @Pratiksha2 ,

where are you stuck in this ?

is your script include returning the correct value called "True"?

can you please put logs and try till where the script is working ?

code is working  to prevent deletion of change request if it has any open change tasks. but I am not able to add confirmation message before deleting record.

@Pratiksha2 so if there are change tasks then you are returning true from Script include and which is preventing the deletion right ? 

 

are you trying to delete the change record in script include and putting the error message in script incldue itself ?

 

If yes try to put the log in UI action code after you return the value from script include

suvro
Mega Sage
Mega Sage

add client script before like below

confirmDelete () {

var confirmDelete = confirm("Do you really want to delete ?"); //confirm returns true if pressed ok and returns false when clicked cancel

if (confirmDelete == true){

Use gsftsubmit to run the server side script

}

}