Hi Community, I need to trigger notifications on sys approval table

rajeshKongamudi
Tera Contributor

Hello Community,

We are attempting to retrieve the "Requested For" and "Opened By" fields from the sysapproval table, but we are currently unable to retrieve these values. We would appreciate assistance in triggering the "Requested For" and "Opened By" fields. Below, I have outlined the trigger conditions and the event script.

We would be grateful for any guidance on how to resolve this issue and implement the necessary enhancement. Thank you in advance for your support.

 

rajeshKongamudi_0-1740473353564.png

Advanced script: 

--------------------------------

(function executeRule(current, previous /*null when async*/) {
    // Add your code here
var values = current.sysapproval.variables;
gs.eventQueue("Freelancer_reject", current, values.requested_by, values.requested_for.email);
})(current, previous);
2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@rajeshKongamudi 

use this in your script

I assume event, notification is on Approval table and Event parm1 contains Recipient checkbox is True

(function executeRule(current, previous /*null when async*/ ) {
    // Add your code here

    var gr = new GlideRecord("sc_req_item");
    gr.addQuery("sys_id", current.sysapproval);
    gr.query();
    if (gr.next()) {
        var values = gr.requested_for.toString() + ',' + gr.opened_by.toString();
        gs.eventQueue("Freelancer_reject", current, values);
    }

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

Sourabh Tarlekr
Kilo Sage

Hi @rajeshKongamudi 

 

Requested for and Opened By are not variables in RITM so we can directly access fields from sysapproval.

Kindly pass below parameters in your query. It should work.

 

 

gs.eventQueue("Freelancer_reject", current, current.sysapproval.requested_for.email,current.sysapproval.opened_by.email);

 

 

If this solution works for you, then kindly mark Accept Solution/Helpful.

 

Regards,

Sourabh

 

View solution in original post

5 REPLIES 5

Sourabh Tarlekr
Kilo Sage

Hi @rajeshKongamudi 

 

Requested for and Opened By are not variables in RITM so we can directly access fields from sysapproval.

Kindly pass below parameters in your query. It should work.

 

 

gs.eventQueue("Freelancer_reject", current, current.sysapproval.requested_for.email,current.sysapproval.opened_by.email);

 

 

If this solution works for you, then kindly mark Accept Solution/Helpful.

 

Regards,

Sourabh