The CreatorCon Call for Content is officially open! Get started here.

Cancel Button in Demand

Al-jhon
Kilo Sage

I created a UI Action to cancel a demand with script below:

But active field is not changing to FALSE.

is there issue with my script? Or i can try BR to update the active field to false?


function cancel() {
    var ans = confirm('Are you sure to cancel the Demand?');
    if (ans == true) {
 
    g_form.setValue('state', 4);
 
    } else {
 
        return false;
    }
    gsftSubmit(null, g_form.getFormElement(), 'canceldemand');
}
 
serverside();
 
function serverside() {
 
current.active = false;
current.update();
 
var workflow = new global.Workflow();
workflow.cancel(current);
 
 
    action.setRedirectURL(current);
    gs.addInfoMessage('Demand has been cancelled');
}
 
 
 
1 ACCEPTED SOLUTION

Hi @Al-jhon You dont need to create a new state to cater this requirement

, you can use OOB rejected option to cancel the Demand. use 7 as value . When demand is rejected, active will be set to false dynamically through OOB script

 

Please chek this OOB business rule to see how demand state works

Demand Active State Management

HarishKM_0-1704863484127.png

 

Regards
Harish

View solution in original post

8 REPLIES 8

Sainath N
Mega Sage

@Al-jhon : Could you try with the below code and make sure that the action name on the UI action is 'canceldemand'.

 

 

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

if (typeof window == 'undefined') {
    current.active = false;
    current.update(); // This commits to DB

    var workflow = new global.Workflow();
    workflow.cancel(current);

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

 

sainathnekkanti_0-1704857485833.png

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Hello @Sainath N , this can cancel the demand but still active is still true.


is it not possible to update active field via script? i will try to create BR.

Aljhon_0-1704863573545.png

 

@Al-jhon : Can you share the screenshot of the UI Action you configured? Also is this log statement printing during click of button?

gs.addInfoMessage('Demand has been cancelled');

Aljhon_0-1704864674307.pngAljhon_1-1704864698666.png