State Changes

mallelakuma
Tera Contributor

Hi Team,

I have a requirement in ServiceNow.

On RITM (Requested Item – sc_req_item), I need to automatically update the Work Notes whenever the State field changes. This should work for all state values (like Open, Pending, Work in Progress, Closed, etc.) and capture the old state and new state.

3 REPLIES 3

GlideFather
Tera Patron

Hi @mallelakuma,

 

it sounds like on after business rule. Create one and share your progress here to help you finalise it

_____
Answers generated by GlideFather. Check for accuracy.

Tanushree Maiti
Kilo Patron

Hi @mallelakuma 

Use  after Business Rule to capture both the prior and updated  state values of a variable.

 

  • Table: sc_req_item
  • When: after
  • Insert/Update: Checked
  • Filter Conditions: State Changes // Mention condition as per your requirement
  • Sample Script:

    //Update script as per your requirement
    (function executeRule(current, previous /*null when async*/) {
          current.work_notes = "State changed from " + previous.state.getDisplayValue() + " to " + current.state.getDisplayValue();
          current.setWorkflow(false); 
        current.update();
    })(current, previous);
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Aditya_hublikar
Mega Sage

Hello @mallelakuma ,

For old value and new value requirement,  in business rule there is current and previous object so you can achieve your requirement using business rule .

 

 

If this helps you then mark it as helpful and accept as solution.

Regards,

Aditya