I need to construct dynamic URL for the approver on knowledge article

SomashekarB
Tera Contributor

Hi,

I need to construct the URL dynamically when email notification is sent to approver for Approve/Reject article. when approver click on "approve/reject" link it should redirect approval page on sysapproval_approver table.

 

Below is URL. If I impersonate and check approver name is not changing dynamically as I have customized to send only one email for all the approvers.

 

obj.approval_link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=sysapproval_approver.do?sys_id=" + current.sys_id + "&sysparm_query=approver=" + gs.getUserID();
9 REPLIES 9

@SomashekarB 

this line is correct and ensure you are parsing the object returned from script include correctly in email script

obj.approval_link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=sysapproval_approver.do?sys_id=" + current.sys_id + "&sysparm_query=approver=" + current.approver;

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

Below is script include which I have parsing object to email script 

var approver_arr = [];
var appr = new GlideRecord("sysapproval_approver");
appr.addQuery('document_id', current.sys_id);
appr.addQuery('state', 'requested');
appr.query();

while (appr.next()) {
    var approver = appr.approver; // Fetching the approver
    approver_arr.push(appr.approver);
    gs.log('Approver found: ' + approver); // Logging the approver
   
}
obj.approval_link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=sysapproval_approver.do?sys_id=" + current.sys_id + "&sysparm_query=approver=" + approver;
 
email script  -
  "Click here to approve / reject the request: <a href='" + obj.approval_link + "'>Approve/Reject</a><br/><br/>" +
       

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @SomashekarB 

I'm not sure about your exact requirement, but why is approval required via impersonation? In production, the impersonation role is not recommended. It's better to use the delegate feature instead.

*************************************************************************************************************
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]

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

Hi,

The requirements were to send the notification to all the approver through email for approve/reject article for publications. Instead sending multiple emails to approver, our leads told change to only 1 email to all the approver as there will be multiple emails copied to author as well. When approver received the notification and click on approve/reject article, the link should redirect to approval page for approve/reject article.

Hi @SomashekarB 

So, from what I understand, the email is being sent to multiple individuals in the group, and instead, you want a single email to go to the group. In that case, can't you use the group email address and untick the "Include Members" option?

*************************************************************************************************************
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]

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