- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 03:32 AM
Hi everybody! I want to add a script in my ui action button for close the case in a certain state. Which script should I use?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 05:20 AM
Hi @Gunjan Kiratkar ! thanks! Also, if I want that a particular state act like the closed state I have to make some other script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 04:07 AM
Hi @Alessia Russo ,
Use below Code in UI action
if(current.state=="10"){ //use your desired state backend value, 10 is for Open
current.state = "3"; //use proper closed choice backend value,3 is for closed
current.update();
gs.addInfoMessage("Case has been closed.");
action.setRedirectURL(current);
}
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 05:14 AM
hi @Gunjan Kiratkar ! So like this the case is closed, but the state remain the one I wanted?
Because I would like that the case is closed but that I see on the form the custom state I want, for ex the n.10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 05:17 AM
Hi @Alessia Russo ,
Whatever state you want, You can mentioned that in line number 2. just cross check the backend value for the choices from dictionary.
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 05:20 AM
Hi @Gunjan Kiratkar ! thanks! Also, if I want that a particular state act like the closed state I have to make some other script?