Condition if a user is not a member of a group

KB15
Giga Guru

It's simple Javascript question:

I'm looking to find how to check if a caller is not part of a group in a notification. I've successfully used isMemberOf to check for a group but not the reverse.


Any help would be appreciated!

10 REPLIES 10

randrews
Tera Guru

you shoudl be able to put an ! in front of the same condition as testing for to make it a not.


KB15
Giga Guru

I'm adding this into the advanced script field in a notification.


can you post the code that works for if they ARE a member and or what you have so far?


Before I get ahead of myself, the point of this is to send an alternate notification when there someone is part of a VIP group.


The ones that are currently in production are horrible and one of the managers have asked to have this done. Eventually, this will won't be necessary once all the notifications are revised. The ones below seem to work.



Standard notification:


Active is true


Task type is "Ticket" (Custom)


Table is "ticket" (Custom)



Adv Script


if (gs.getUser(current.task_for).isMemberOf('VIP Users')) {


  answer = false;


  } else {


  answer= true;


  }



The VIP notification is the same except for the adv script:


gs.getUser().getUserByID(current.task_for).isMemberOf('VIP Users');



The other notifications sit on the incident table and I've also experimented with caller_id but that doesn't seem to work either. I believe that our ticket table is extended from task.


ok if i am not mistaken... to tell if they are not a member in the most economical method you could just put an ! in front of the gs.getUser....   that whole thing will return true if the user is a member of VIP users.. and if you put an ! in front of it.. it should flip <not> the results...



however a far simpler method would seem to be to just flip where you put your true and false.