Add cancel button in a Demand when in Draft State only

GB14
Kilo Patron

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?  

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Gurbir,

 

You can create a UI action from System UI >> UI Action named Cancel on Demand (dmn_demand) as below.

find_real_file.png

 

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. 

View solution in original post

12 REPLIES 12

sachin_namjoshi
Kilo Patron
Kilo Patron

You can use OOB UI action "Defer" to defer demand which is in draft stage

 

find_real_file.png

 

Regards,

Sachin

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. 

- 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

find_real_file.png

- 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

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)