To check initiator is a member of a group in Workflow

Hi Guys,

I have a requirement in which, i need to check if the initiator is a member of a particular team/Group. If he is, then the request should be forwarded without manager approval. The initiator is a DN in my workflow.
So for this i have added a condition in the workflow just before manager approval. Here i need to check if the initiator is member of the team.
I tried some options but couldn't succeed.
Can anyone help me with some solutions?
Parents
  • Hi Guys,
    I used the following script in a condition activity in Workflow. But still i am not able to get the output. I am getting the output of this script as false, even if the initiator is a member of admin group
    // Check if initiator is a member of Admin Team
    function compare(){
    var result = false;
    var groupDN= "cn=Admin,ou=Groups,o=company" ;

    var initiatorDN = initiator;
    var groups=IDVault.get(initiatorDN ,'user','groupmembership');
    for (var i=0; i<groups.length; i )
    {
    if(groups==groupDN)
    {
    result = true;
    }
    }
    return result;
    }
    compare();

    Does anyone know how, the IDVault.get query works for returning an array and how to use this array to check if the user is a member of a group?
  • Here's code to look up group objects for something else, but it has the type checks on the result which is what you'll be after.....

    try{
    var notifGroupMails = IDVault.get(objectDN, 'xxxGroup', 'xxxGroupEmailAddresses');
    trace("findNotificationEmails(): notifGroupMails " notifGroupMails.toString(), 3);
    if (notifGroupMails != null)
    {
    if (typeof notifGroupMails === "string")
    {
    toaddresses.push(notifGroupMails);
    }
    if (typeof notifGroupMails === "object")
    {
    for (var g = 0; g < notifGroupMails.size(); g )
    {
    toaddresses.push(notifGroupMails.get(g));
    }
    }
    }
    }
    catch(e3)
    {
    trace("findNotificationEmails(): Error " e3, 1);
    }


    Don't forget that you may want to .toLowerCase() during compare. e.g.:

    if(groups.toLowerCase()==groupDN.toLowerCase())
  • Thank you scorpion sting,

    Actually in the workflow condition activity, when i used .size(notifGroupMails.size()) function, i was getting an error in the log saying size is not a function.
    Thats why i used .length function (groups.length) to get the length of the returned array.
Reply Children
No Data