Cancel Case Custom UI Action is requiring resolution code and also not saving the values

spears49
Tera Contributor

I have a custom 'Cancel Case' UI Action that needs to cancel a case. I am able to get it to send the confirmation message to cancel but there is a mandatory field that is needed to be entered before it will cancel. How can I set the value of the 'resolution_code' field before saving and submitting the action. Below is my current code: This code will do what is necessary by prompting for the information but you either have to click save after entering the value or go through the steps again if you don't enter a resolution code first. Is there a way to set the resolution code in the UI Action and save and submit?

 

function cancelCase() {
    var answer = confirm('Are you sure you want to cancel this Cyber Case?');
    if (answer == true) {
        g_form.setValue('state', 7);
        gsftSubmit(null, g_form.getFormElement(), 'cancel_case');
        g_form.save();
    } else {
        return false;
    }
}
if (typeof window == 'undefined')
{
    current.state = 7;
    current.update();
    action.setRedirectURL(current);
    gs.addInfoMessage('This Cyber Case is cancelled.');
   
}
1 ACCEPTED SOLUTION

Zach Koch
Giga Sage
Giga Sage

If the resolution_code field is on your form where you are clicking the UI action, then you can just use g_form.setValue('resolution_code', yourValue), like you are already doing to set the state. If it's on a different form, then you would need to look up the record with server side code and set it there.

 

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!

View solution in original post

3 REPLIES 3

Zach Koch
Giga Sage
Giga Sage

If the resolution_code field is on your form where you are clicking the UI action, then you can just use g_form.setValue('resolution_code', yourValue), like you are already doing to set the state. If it's on a different form, then you would need to look up the record with server side code and set it there.

 

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!

spears49
Tera Contributor

This worked for me! The first time I tried it, I got errors and it didn't save the changes. One follow up question. What approach would you take to make the fields read only on cancel?

Glad that helped. To make all fields read only once the record is cancelled, you'd most likely need to look into ACLs. You could use Data policies, but would require a lot of configuration, or UI policies, but that would only stop editing on the form, not from the list, so your best bet would be to look into the table.* write ACL and adjust it so no fields are editable when state = canceled. If you needed only particular fields, then you'd need to look at table.field write ACLs for those fields, and if there aren't any, create them for the ones you need.

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!