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

Ankur Bawiskar
Tera Patron
Tera Patron

@SomashekarB 

it should be this

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

Still the approver name is not changing dynamically when I Impersonate approver 

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;

@SomashekarB 

please share the complete script and event, notification is which table?

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

Script include 

getNotifiObject: function(current) {
        var obj = {};
        var kb_id = current.document_id;
        var gr_kb = new GlideRecord(current.source_table);
        if (!gr_kb.get(kb_id))
            return obj;
        obj.number = gr_kb.number;
        //obj.approval_link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=sysapproval_approver.do?sys_id=" + current.sys_id;
        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;
        obj.short_desc = gr_kb.short_description;
        obj.article_body = gr_kb.text;
        obj.article_link = gs.getProperty('glide.servlet.uri') + "nav_to.do?uri=kb_knowledge.do?sys_id=" + gr_kb.sys_id;
        obj.approver = current.approver.first_name;
        return obj;
    },
-------------------
Email Script
SomashekarB_0-1740764970356.png
BR triggering from event to have single email to all the approver ,
(function executeRule(current, previous /*null when async*/ ) {

    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()) {
        //     approver_arr.push(appr.getValue('approver'));
        approver_arr.push(appr.approver.email);
 
    }
    if (approver_arr.length > 0) {

       
        gs.eventQueue('sn_gsm.approval.requestedfor.kb', appr, approver_arr.toString());
    }


})(current, previous);
---------------------------------

notification trigger from sysapproval table