Solved

Expression to check agent group membership

  • 7 February 2023
  • 6 replies
  • 158 views

Userlevel 3
Badge +7

Hi,

I have a need to set up a condition in a work flow that checks if the requester of a ticket is member of specific Agent group. I haven’t found any standard way of doing this so I have tried with api calls and expression builder but without success.

I’m using a web request to get the group details and a json parser node to structure the output. But how can I use the Expression builder to check if the ticket requester is member of the group or not? Anyone managed to do such a check?

The web request returns an array or numbers for the group members which I assume is part of the problem.

icon

Best answer by Daniel Söderlund 7 February 2023, 16:47

View original

6 replies

Userlevel 7
Badge +13

Hello, you could use something like this. I have hade issues when I have a , in the text in the placeholder it’s why I’m replacing it with - 

if(regexMatch(‘{{placeholder from the parser node | replace: ',', '-'}}’,{{requester ID placeholder}},”The requester is in the group”,”Not in the group”) 

 

Userlevel 3
Badge +7

@daniel.soderlund  Thanks for the response. I think I am one step closer now :)

But I’m not getting it to work still. As a test I tried to just add the result from the expression builder as a ticket note using part of your suggested code and the results are “[]” which is a result of the “array of numbers” I guess. See the pictures below if that helps.

 

 

Userlevel 7
Badge +13

@daniel.soderlund  Thanks for the response. I think I am one step closer now :)

But I’m not getting it to work still. As a test I tried to just add the result from the expression builder as a ticket note using part of your suggested code and the results are “[]” which is a result of the “array of numbers” I guess. See the pictures below if that helps.

 

 

Can you click on the view array of number and paste it here ? 

Userlevel 3
Badge +7

Here is how it looks in the array. The content is the same for all 4 arrays.

 

But I’m beginning to think I might be doing something wrong earlier in the flow that might be feeding an empty array to the json parser, will check on that later today or tomorrow when time allows. Would an empty array result in “[]” or would that render some other result?

Userlevel 7
Badge +13

Here is how it looks in the array. The content is the same for all 4 arrays.

 

But I’m beginning to think I might be doing something wrong earlier in the flow that might be feeding an empty array to the json parser, will check on that later today or tomorrow when time allows. Would an empty array result in “[]” or would that render some other result?

Yes, you can always create private note with the placeholder to see the outcome 

Userlevel 3
Badge +7

@daniel.soderlund  Thanks for the help!

Your initial response solved my issue.

I had done a mistake earlier in the workflow as I suspected and when I corrected that it worked with your input.

Reply