How to set 'close code' choice field when change request form's state changes to cancelled?

Nitin21
Tera Contributor

How to set 'close code' choice field in change request form to 'Cancelled' when the state of change request changes to 'Cancelled' ?

2 ACCEPTED SOLUTIONS

Try below code in script section.

 

(function executeRule(current, previous /*null when async*/) {
current.close_code="successful_issues"; // Change the value of close code
current.update();
   
})(current, previous);
 
 
Thanks.

View solution in original post

Robbie
Kilo Patron
Kilo Patron

Hi @Nitin21,

 

Do you want the Close Code to be set by the system in an automated fashion with the same value every time such as the value of 'Cancelled' for example (depending on what codes have been implemented on your system) or do you want this to be selectable by the user when the Change is Cancelled?

 

There are various ways to solve this each differing in complexity, however, my recommendation would be to automate this and have a simple Business Rule set this for you. The State change and Cancellation reason is captured as part of the baseline configuration so the Business Rule option outline below should provide a suitable solution.

 

See the below screenshots for a low-code/no-code option.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 

(When to run Tab)

Screenshot 2024-03-13 at 10.13.05.png

(Actions Tab)

Screenshot 2024-03-13 at 10.13.16.png

View solution in original post

7 REPLIES 7

AndersBGS
Tera Patron
Tera Patron

Hi @Nitin21 ,

 

The close code can be set by a business rule so whenever change request is cancelled the closed code will change to something...

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Hi thanks, I did write an 'after' business rule, but it did not set the choice field after the change request is cancelled. However, the message was shown. Do i need to write script in advanced section, if so can you please help with the script.

 

Try below code in script section.

 

(function executeRule(current, previous /*null when async*/) {
current.close_code="successful_issues"; // Change the value of close code
current.update();
   
})(current, previous);
 
 
Thanks.

Thank you! Dhananjay. It worked. 🙏