Set a state with UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2022 05:34 AM
Hi everybody! I need to set a particular state in a case by clicking a button from his task. I've created in the task a ui action that set the task state in waiting for approval, but I also want that by clicking that button it change the state of his case in "to be approved". So it will show the case in to be approved state and the task in waiting for approval.
which script should I use in the ui action? Or should I use a script in a policy or br? Thnx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2022 05:37 AM
What do you have in your UI action so far? On which table it is and what is the relationship between "task" and "case" as you mentioned above? Could you add some screenshots by any chance? It is not entirely clear what you are trying to achieve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2022 05:50 AM
For now I've only set with an ui action that the state of my task is in 'waiting for approval', but I would like to know if I've to add an other script for change also the state of case that contain this task.
 Here the button in the task:
here the state of the case that I want to change by clicking that button on the task:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2022 06:59 AM
Hi @Alessia Russo , You can use below script in same UI action (i.e Task UI action)
var caseNumer = current.case_number_field; // pass the field name which store 'case number' on task table
var gr = new GlideRecord('caseTable'); // provide case table
gr.addQuery('sys_id', caseNumer );
gr.query();
if (gr.next()) {
gr.state = 2; // Choice value of "to be approved" state
}
gr.update();
Please mark answer correct/helpful based on impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2022 07:21 AM
Hi @Sonu Parab ! I've tried but it didn't work, I've used it like this:
(function(){
current.state = 132; // set the opened task state to in progress
current.update(); // update the opened task to save the changed state
gs.setRedirectUrl(current); //redirect back to open case.
})();
var caseNumer = current.case_parent_field; // pass the field name which store 'case number' on task table--> the name of the field (number of the case) is parent
var gr = new GlideRecord('sn_customerservice_case'); // I write here the case table (I don't know if I make it correct)
gr.addQuery('sys_id', caseNumer );
gr.query();
if (gr.next()) {
gr.state = 201; // Choice value of "to be approved" state
}
gr.update();
can you tell me if I did something wrong pls? Thnx