Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Send notification to the knowledge admin user

Priti Deshmukh
Tera Contributor

Need to add recipient as a knowledge admin in the notification.

I have tried both the script in advanced condition of notifications-

answer = false;
 if (gs.hasRole("knowledge_admin")) {
   answer = true;
 }
AND
function userHasRole() {
    var userGr = new GlideRecord("sys_user_has_role");
    userGr.addQuery('user', current.session_user); //field on the record who will be the recipient
    userGr.addQuery('role.nameINknowledge_admin');
    userGr.query();
    if (userGr.next()) {
        return true;
    } else
        return false;
}
 
But there is no notification for knowledge admin role is triggered.
 
2 REPLIES 2

Sid_Takali
Kilo Patron

Hi @Priti Deshmukh try this code

if (gs.hasRole('knowledge_admin')) {
    answer = true;
} else {
    answer = false;
}

 

Regards,

Sid

AnimeshP_96
Kilo Sage

hey @Priti Deshmukh 
so just for understanding , you need to send notifications right so why not create a record in notifications table for knowledge table, add users role for knowledge_admin and also let me know what is the condition for triggering notification...


Please accept the solution /mark this response as correct or helpful if it assisted you with your question.




Regards,
Animesh