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

We are trying to avoid Delete button.

Naveen Sagar S1
Mega Guru

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. 

Hello Jaspal, 

I added a process flow and state called Canceled (state value 12)

after i hit "cancel" i see the state changing from "Draft" to "Canceled" but when i go back to demand to double check, its reverted back to Draft. 

 

find_real_file.png

 

function callme() {
var ans = confirm('Are you sure you want to cancel the Demand?');
if (ans == true) {
g_form.setValue('state', '12');
} else {
return false;
}
gsftSubmit(null, g_form.getFormElement(), 'confirmcancellation');
}

serverside();

function serverside() {

current.update();
action.setRedirectURL(current);
gs.addInfoMessage('Demand has been cancelled');
}

 

Add

current.state='12'; just before current.update(); & it should work