0

Notifications : How to Send dynamic link in email notification to users in watchlist, Assign_to, Requested for, based on their roles:-

Create Event : users.custom.link

Create Notification – Call above event in your notification with event trigger type

Create Business Rule with below code with your trigger conditions:

(function executeRule(current, previous /*null when async*/ ) {
var getRequestedFor = current.request.requested_for;
gs.eventQueue("users.custom.link", current, getRequestedFor, "true");
var getUsers = current.assigned_to + "," + current.watch_list;
var getUsersSplit = getUsers.split(",");
for (var i = 0; i < getUsersSplit.length; i++) {
var checkRole = newGlideRecord("sys_user_has_role");
checkRole.addEncodedQuery("user.sys_idIN" + getUsersSplit[i] + "^role=282bf1fac6112285017366cb5f867469^ORrole=3be5d3d1b7103300dff9fa13ee11a987");
checkRole.query();
if (checkRole.next()) {
gs.eventQueue("users.custom.link", current, getUsersSplit[i], "true");
} else {
gs.eventQueue("users.custom.link", current, getUsersSplit[i], "false");
}
}
})(current, previous);

Create Email Script : users_custom_link

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    if (event.parm2 == "true") {
        template.print('<p><a href="sc?id=tickt&amp;table=sc_req_item&amp;sys_id=${sys_id}&view=sp"><button style="background-color: #0071b9; border-radius: 5px; height: 39px; width: 175px; font-size: 15px; font-weight: bold; border-width: 0px; cursor: pointer; color: white;">View ${number}</button></a></p>');
        template.print('</font></p>');
    }
})(current, template, email, email_action, event);

Call the email script in your notification. : ${mail_script:users_custom_link}

How to send dynamic link in email notification to users based on their roles
admin Changed status to publish December 16, 2023
Sorry, you do not have permission to read comments.