Ui Action Cancel Button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 03:03 AM
Hi All,
Can any one please help with the requirement.
When a user cancels , the pop-up should require a in that popup only user to input a cancellation reason.
- and that comment popup should be mandatory when we click on cancel.
- after that it should be added to the work notes
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 12:56 PM
On the the UI Action:
Action name: cancel_request
Client: true
Onclick: confirmCancel()
Ui action script:
function confirmCancel(){
if(confirm('Are you sure you want to Cancel?')){
var reason = prompt("Why do you want to cancel?");
if(reason){
//If you wish to capture the reason on the record
g_form.setValue('<field>',reason);
}
gsftSubmit(null,g_form.getFormElement(), 'cancel_request'); //UI Action > Action name
}else{
return false;
}
}
if(typeof window == 'undefined'){
cancelRequest();
}
/**
* Cancels the record and reloads the page
*/
function cancelRequest(){
action.setRedirectURL(current);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 08:13 PM
- Create a new UI Action:
- Go to the Form Layout for the record you want to modify (such as the Incident or Request form)
- Click on the UI Actions related link
- Click on New to create a new UI Action
- Configure the UI Action:
- Set the Name of the UI Action, such as "Cancel with Reason"
- Set the Table to the record type you want to modify (such as Incident or Request)
- Set the Action Name to "Cancel"
- In the Script field, enter the following code:
if (confirm('Are you sure you want to cancel this record?')) {
var reason = prompt('Please enter a cancellation reason:');
if (reason) {
g_form.setValue('close_notes', reason);
gsftSubmit(null, g_form.getFormElement(), 'cancel');
} else {
alert('A cancellation reason is required.');
}
}
This code will display a confirmation dialog when the Cancel button is clicked, and prompt the user to enter a cancellation reason in a pop-up dialog. If the user enters a reason, the reason will be set as the value of the close_notes
field (which is the work notes field for some record types), and the record will be cancelled. If the user does not enter a reason, an alert message will be displayed.
- Save the UI Action and test it on the form.
---------------
Regards,
Rajesh Singh