Script to check if requestor is a manager of any group or not

Siddharth4
Tera Contributor

Hi All,

 

In the workflow script, my goal is to initiate an event that sends a notification to the requestor's manager exclusively when the requestor holds the role of owner or manager within any group. Although I've been working with the script below, I'm encountering challenges in incorporating a condition that ensures the event is triggered only if the requestor is an owner/Manager of any group. In this script, we've included the manager's name in an event query parameter. I would appreciate your assistance in suggesting or providing a revised script that addresses this condition

 

 

var req = current.request.requested_for.toString();
var requestor_manager = current.request.requested_for.manager.toString();
gs.eventQueue('appservice.inactiveuser.notification',null,current.request.requested_for.manager.toString(),current.request.requested_for.toString());

 

1 REPLY 1

SunilKumar_P
Giga Sage

Hi @Siddharth4, Can you try the below script?

var req = current.request.requested_for.toString();
var requestor_manager = current.request.requested_for.manager.toString();

var isManager = false;
var grGroup = new GlideRecord('sys_user_group');
grGroup.addQuery('manager', req);
grGroup.query();
while (grGroup.next()) {
    isManager = true;
    break;
}

if (isManager) {
    gs.eventQueue('appservice.inactiveuser.notification', null, requestor_manager, req);
}

 

Regards

Sunil