Automating deactivation of unused Standard Change Templates after 6 months

akashyada1
Tera Contributor

Hi Team,

I have a requirement to automate the deactivation of unused Standard Change Templates and would like guidance on the best approach.

Requirement:
If the following conditions are met:

Template is Active = true
The Last Closed Proposal Closed Date is older than 6 months from the current date
The Last Change execution (states like Closed / Implement / Review) is also older than 6 months
Then the system should:

Automatically deactivate the template

3 REPLIES 3

maliksneha9
Mega Sage

Hi,

You can achieve this requirement using a scheduled job + script. Below is a recommended approach:

  1. Create a Scheduled Script Execution:- Run daily/weekly depending on your need.
  2. Query Standard Change Templates
    • Table: std_change_template
    • Condition: active = true
  3. Validate the 2 conditions
    • Last Closed Proposal Closed Date
      • Reference table: std_change_proposal (or related proposal table)
      • Check if the latest closed proposal date is older than 6 months.
    • Last Change Execution
      • Table: change_request
      • Filter by template and states like Closed / Implement / Review
      • Get the most recent execution date and verify it's older than 6 months.
  4. Deactivate Template
    • If both conditions are satisfied → set active = false

Dr Atul G- LNG
Tera Patron

Hi @akashyada1 

The approach is good, but you need to execute the query in two steps. First, query the change table to retrieve records older than six months. From those results, you will get the template names. Then, use those template names to query the template table[std_change_record_producer] and deactivate the corresponding records.

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Dr Atul G- LNG
Tera Patron

You can use the flow designer for thism which is low code/no code.

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************