Ui action cancel button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2020 02:46 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2020 09:12 AM
Hi Bharathi,
Try repolacing with below code
(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;
// TRY either of below
current.setWorkflow(false);
/* OR
var workflow = new Workflow();
workflow.cancel(current);
*/
current.update();
gs.addInfoMessage('Case has been cancelled');
action.setRedirectURL(current);
}
Thanks!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2020 07:30 AM
So, you are using the standard methods such as:
g_form.setMandatory('close_code', false);
g_form.setMandatory('close_notes', false);
Are you then seeing something like "Invalid Update"? You might need to look into the data policies against the table in question as you can't influence those from the client side (even setting the fields as not mandatory would still produce the error.
If there are data policies (which you probably can't remove) you could potentially set values in all of the required fields within your UI action...
If this was helpful, or correct, please be kind and remember to mark appropriately!
Michael Jones - Cloudpires
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2020 08:46 AM
Hi Michael,
Even if i make my client scripts that i have written to make the fields mandatory to inactive and then try cancelling the case (with my ui action code active), doesnot change my state to cancelled.
Thanks,
Iniya