How to add confirmation message before deleting change request record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2022 10:52 PM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2022 10:58 PM
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2022 11:07 PM - edited 11-13-2022 11:07 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2022 11:15 PM
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2022 10:58 PM - edited 11-13-2022 10:59 PM
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
}
}