Script for close a case

Alessia Russo
Tera Expert

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

1 ACCEPTED SOLUTION

Hi @Gunjan Kiratkar ! thanks! Also, if I want that a particular state act like the closed state I have to make some other script?

View solution in original post

6 REPLIES 6

Gunjan Kiratkar
Kilo Patron
Kilo Patron

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

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 

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

Hi @Gunjan Kiratkar ! thanks! Also, if I want that a particular state act like the closed state I have to make some other script?