- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 11:33 AM
We need to add the "Cancel Demand" button to a demand form.
Canceled state is not available oob so we created the state manually.
We want a popup to confirm and then request canceled.
What would be UI action script to add the button?
Solved! Go to Solution.
- Labels:
-
Demand Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 12:06 PM
Hi Gurbir,
You can create a UI action from System UI >> UI Action named Cancel on Demand (dmn_demand) as below.
function callme() {
var ans = confirm('Are you sure you want to cancel the request?');
if (ans == true) {
g_form.setValue('state', '5'); //suppose 5 is state value for Cancel that you have created
} else {
return false;
}
gsftSubmit(null, g_form.getFormElement(), 'confirmcancellation');
}
serverside();
function serverside() {
current.update();
action.setRedirectURL(current);
gs.addInfoMessage('Demand has been cancelled');
}
Kindly ensure you have additional state choice created & if so pass in the script accordingly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 11:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 11:41 AM
Thank you for your response Sachin. We are currently using the Defer to put the demand on hold and want to create a new option to cancel the demand.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 11:52 AM
- First, do you already have state choice list value of cancelled for demand table? If not, then first you will have to add new choice list value of cancelled for demand table.
- you need to configure new process flow for cancelled stage in flow formatter
- Then, use below code in your UI action to cancel demand.
current.state = '12'; // add cancel state choice list value as per your instance
current.submitted_date = gs.now();
current.submitter = gs.getUserID();
current.update();
action.setRedirectURL(current);
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 01:10 PM
Thanks again Sachin,
The process has been added. When I click cancel it brings state "12" instead of cancel. (Cancel state order is 12 in the process flow)