The CreatorCon Call for Content is officially open! Get started here.

Change the Approver according to Category and sub-category

Ashishsk
Tera Contributor

Change the Approver according to Category and sub-category in Change Request/ Management, Example if the Category- backup & Sub-Category-Data Domain then Approver should be XYZ like this we have more than 250 record Can you please provide the solution for it.

3 REPLIES 3

tusharhirpurkar
Tera Contributor

Hi Abhishek,

 

Please refer below link it might help you:-

https://www.servicenow.com/community/developer-forum/change-approval-process-based-on-category-subca...

 

Thanks,

Tushar

Maddysunil
Kilo Sage

@Ashishsk 

You can write before insert/update business rule on change request table and in script you can call script include to get the approver based on category and subcategory:

below is sample template you can use:

BR:

 

(function executeRule(current, previous /*null when async*/) {

    var category = current.category.toString(); 
    var subCategory = current.sub_category.toString(); 

    // Call the Script Include to get the appropriate approver
    var approverScript = new ApproverAssignmentScriptInclude();
    var approver = approverScript.getApprover(category, subCategory);

    // Update the assigned_to field with the calculated approver
    if (approver) {
        current.assigned_to = approver; // Assuming assigned_to is a reference field
    }

})(current, previous);

 

  Script include:

 

var ApproverAssignmentScriptInclude = Class.create();
ApproverAssignmentScriptInclude.prototype = {
    initialize: function() {},

    getApprover: function(category, subCategory) {
       // define you logic to get the approval and return
    },

    type: 'ApproverAssignmentScriptInclude'
};

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Ashishsk 

 

You can make changes in Change approval policy and put these cat- sub cat as condition. but remember mate, once arrival generated, it will not be reverted until unless change move back in new state.

 

or if you have specific case, better use Change Model.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

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/atul_grover_lng [ Connect for 1-1 Session]

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