Ui action cancel button

Inya
Tera Contributor

Hi all,

 

 

If  the user opens a case , I have set a 'cancel button' which he can click on to cancel the case.

Before he cancels, a confirmation box appears. If he clicks ok (on true), then i have to set the state of the current case to cancelled.

The issue here is there are a set of mandatory fields that blocks this action on OK, that must be disabled which is not happening when i try to use g_form.setmandatory = false before i set the state to cancelled.

I tried the basic methods and strategy to achieve this , but is not happening. Please help out.

 

Thanks,

Iniya

7 REPLIES 7

Knight Rider
Mega Guru

Hi,

Use thsi below script in your UI action to set all mandatory fields to false.

g_form.checkMandatory= false;

Please mark as Correct/Helpful, If this helps!!

Hi KnightRider,

 

Sorry for the typo, I actually used the checkMandatory = false in my UI action already and even then it was not working

Hi,

Can you try replacing with this below code in your script to make  all fields Mandatory false.

for(var x = 0; x < g_form.elements.length; x++)
{
g_form.setMandatory(g_form.elements[x].fieldName, false);
}
}

 

Also, add current/gr.setWorkflow(false); -   which stops all other business rules to not to execute.

If  still you have the issue. Please attach a snippet of your UI action.

 

Thanks!!

 Please mark as Correct/Helpful, if this helps!!

Hi KnightRider,

 

Please check the UI code below that i wrote for cancel.THe mandatory fields doesn't become false nor the state changes, simply the screen goes away as if its getting saved or it loads with no change in state to cancelled.

(For making the those fields to mandatory i used client script actually)

/*UI code for cancel*/

function runClientCode(){
var confirmation = confirm("By cancelling the case you confirm that you will not be travelling to Switzerland");
if(confirmation == false){
return false; //Abort submission
}
//Call the UI Action and skip the 'onclick' function
else{
for(var x = 0; x < g_form.elements.length; x++)
{
// alert("heya"+g_form.elements[x].fieldName);
g_form.setMandatory(g_form.elements[x].fieldName, false);

}
// g_form.setValue('state',401);
gsftSubmit(null, g_form.getFormElement(), 'sysverb_cancel');
}
}
//Ensure call to server-side function with no browser errors
if(typeof window == 'undefined')
runBusRuleCode();

//Server-side function
function runBusRuleCode(){
current.state = 401;
current.update();
gs.addInfoMessage('Case has been cancelled');
action.setRedirectURL(current);
}