if new ritm and old rejected ritm having same details need to send email with rejected ritm details

venkat_guthik
Tera Guru

Hi Community,

I have a requirement that when we creates new RITM through catalog(manual/automation tickets),
If newly created RITM and Rejected old RITM having the same details(any one of common fields), we need to trigger an email notification with the old rejected RITM details with that approval Rejection comments.
I have created notification on "sysapprover" table with event fired condition through Business rule(after update & state changes to rejected). (this single rejection comments i can able to trigger correctly).

But as per my requirement i need to trigger when new RITM created. I have created new Business rule after insert on Requested_item table and called the same event. It is not working.

Can anyone please suggest on this. Is this correct way or not ? 
Can we implement this scenario or not please suggest

5 REPLIES 5

Mark Manders
Mega Patron

It sounds like a very weird requirement. What do you see as 'common fields'? I understand that you don't want anyone to keep on creating the same RITM that keeps on being rejected, but the same RITM could have other justification, right?

 

But your logic won't work, because you can't retrigger a notification from a different ticket. You could create a flow on creation of a RITM that checks if there are any older, rejected ritm's with those 'common' fields. If so, use the 'send email' action to create an new notification, including the rejection note of the old approval in the text (or use the 'send notification' action to use a created notification in which you use an email script to get the old rejection note'). 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

@Mark Manders 
Hi Mark,
Here i have the common fields are Application ID & Owner Name etc.
If new RITM created with same Application ID, owner wants to know that why the previous RITM is Rejected by the Approver. This old RITM- approval rejected comments are helpful to them to understand the creation of the new RITM.

When Iam using Business Rule with Event triggered condition, it is checking only current record. Not checking the old Rejected RITM approver details.

Pls help me... how can i configure this requirement in the flow.


(function executeRule(current, previous /*null when async*/) {
// Define matching criteria (fields to compare)
var matchCriteria = {
'short_description': current.short_description,
'catalog_item': current.cat_item,
// Add more fields if necessary
};

// Query rejected RITMs with the same matching criteria
var rejectedRitms = new GlideRecord('sc_req_item');
rejectedRitms.addQuery('state', 'rejected'); // Assuming 'rejected' is the state value
rejectedRitms.addQuery('short_description', matchCriteria.short_description);
rejectedRitms.addQuery('cat_item', matchCriteria.catalog_item);
// Add more query conditions based on your criteria
rejectedRitms.query();

// If a rejected RITM is found, send an email
if (rejectedRitms.next()) {

gs.eventQueue(....);
}
})(current, previous);

Thanks Manikanta for your reply.
By using your script, I can able to validate the new and old rejected RITM's and can able to trigger the mail through event.
But i can't able to capture the old RITM  approval rejected comment's in the same mail.