How to differentiate between approvals for change requests and RITMs

Cat
Giga Guru

Hi All,

 

I'm trying to implement approvals on RITMs and I'm using the approval.inserted event, however, that seems to also be used currently (in our environment) for change approvals.

Which event differentiates between approvals for change and approvals for RITMs?

 

Thanks in advance for any help!

2 ACCEPTED SOLUTIONS

Dr Atul G- LNG
Tera Patron

Hi @Cat 

If the event is the same, we can add a condition in the email notification where the ticket number starts with CHG or RITM.

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

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

View solution in original post

@Cat

if you want different email content then separate them out

1) update OOTB to include source table  = sc_req_item (Since you are updating OOTB it will be skipped during upgrade)

2) create new notification with exact same event etc source table = change_request

OR
update the email scripts I shared as per your requirement

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

 

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

If it works, that’s great! I thought adding the condition wouldn’t work properly in the same setup, but I’m glad it does

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

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

@Cat 

this will work

Note: If you are updating OOTB notification then it will be skipped during the upgrade, that's the only risk

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

VaishnaviK43271
Tera Contributor

Hi @Cat !!

There is no separate event for approvals created for Change versus RITMs.

The approval.inserted event is a generic event and is fired for all approvals in the platform, including:

  • Change approvals (change_request)

  • RITM approvals (sc_req_item)

  • Request approvals (sc_request)

  • Other approval-enabled tables

How to Differentiate Between Change and RITM Approvals

You must evaluate the source record of the approval.

On the sysapproval_approver record, the sysapproval field references the record that generated the approval.

Example logic:

var sourceGR = current.sysapproval.getRefRecord();

if (sourceGR.getTableName() == 'sc_req_item') {
    // RITM approval
} else if (sourceGR.getTableName() == 'change_request') {
    // Change approval
}

 

Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.

Regards,
Vaishnavi
Associate Technical Consultant

VaishnaviK43271
Tera Contributor

Hi @Cat !!

There is no separate event for approvals created for Change versus RITMs.

The approval.inserted event is a generic event and is fired for all approvals in the platform, including:

  • Change approvals (change_request)

  • RITM approvals (sc_req_item)

  • Request approvals (sc_request)

  • Other approval-enabled tables

How to Differentiate Between Change and RITM Approvals

You must evaluate the source record of the approval.

On the sysapproval_approver record, the sysapproval field references the record that generated the approval.

Example logic:

 

var sourceGR = current.sysapproval.getRefRecord();

if (sourceGR.getTableName() == 'sc_req_item') {
    // RITM approval
} else if (sourceGR.getTableName() == 'change_request') {
    // Change approval
}

 

 

Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.

Regards,
Vaishnavi
Associate Technical Consultant

Ankur Bawiskar
Tera Patron

@Cat 

OOTB this event "approval.inserted" and email notification "Approval Request" is triggered on any approval insertion

This is same for CHG and RITM.

So you can't differentiate there.

AnkurBawiskar_0-1768986925777.png

 

You can differentiate that in the email scripts used by that OOTB Notification

These 2 email scripts are used by that email template

AnkurBawiskar_1-1768987204355.png

AnkurBawiskar_2-1768987231071.png

 

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader