You are viewing limited content. For full access, please sign in.

Question

Question

Forms Filters Javascript - Not sending to the correct user Filter specified

asked on January 24, 2018

Hi All, 

 

Seeing if someone can assist in this: 

 

I have a form that needs to go to specific User Roles based on who is submitting the form. I have created a team to assign it to the specific user(s). Attached is the script. 

 

if($util.getValue('Employee_Name_') == 'user1', 'user2', 'user3', 'user4', 'user5', 'user6')
{
$result=team.findMembersByRole('CEO');
}
if($util.getValue('Employee_Name_') == 'user7', 'user8', 'user9', 'user10')
{
$result=team.findMembersByRole('CEO', 'Team Leader');
}
if($util.getValue('Employee_Name_') == 'user11', 'user12')
{
$result=team.findMembersByRole('CEO', 'Finance Manager');
}
if($util.getValue('Employee_Name_') == 'user13', 'user14', 'user15', 'user16')
{
$result=team.findMembersByRole('CEO', 'Regional Manager');
}
if($util.getValue('Employee_Name_') == 'user17', 'user18')
{
$result=team.findMembersByRole('CEO', 'Multimedia Manager');
}
if($util.getValue('Employee_Name_') == 'user19', 'user20')
{
$result=team.findMembersByRole('CEO', 'Research Manager');
}

What seems to be happening though, is that if I test using "User1" to see who it will return, it returns 2 users (CEO and Research Manager). Basically, it is always defaulting to the last rule set in the code? 

 

No idea why this would be the case? It is always defaulting to the last code set and the users within that script? 

 

Can anyone advise? 

 

Thank you

Ziad

0 0

Replies

replied on January 24, 2018

Hi Ziad,

When you use ($util.getValue('Employee_Name_') == 'user1', 'user2', 'user3', 'user4', 'user5', 'user6') as condition, did you mean to check if $util.getValue('Employee_Name_') belongs to a list ['user1', 'user2', 'user3', 'user4', 'user5', 'user6']?

If so, you should use condition like this:

(_.indexOf(['user1', 'user2', 'user3', 'user4', 'user5', 'user6'], $util.getValue('Employee_Name_')) > -1 )

Your condition ($util.getValue('Employee_Name_') == 'user19', 'user20') will return 'user20' instead of true/false, and if ('user20') will be considered as if (true).

0 0
replied on January 24, 2018

Hi Rui, 

 

($util.getValue('Employee_Name_') == 'user1', 'user2', 'user3', 'user4', 'user5', 'user6') is the logged on user from a Text Field that is auto populated when the user starts the process. The idea is to try pick up who is logged in and assign them to the correct Team member for approval. 

 

Hope this helps? 

Ziad

0 0
replied on January 24, 2018

Hi Rui, 

 

I have made the amendment to the script and it looks like it will work i would like with huge thanks :) , only thing is, because of the 1000 character limit, I am unable to finish the whole script? is there a way i can only target the first name match? to reduce the characters used? 

 

 

0 0
replied on January 24, 2018

Hi Ziad,

Maybe an easier way for you is to have a lookup / stored procedure in a database that will return the Department Role based on Username / displayname. Then all you should need to do is write one or two lines for the filter?

0 0
replied on January 24, 2018

Hi Aaron, 

 

We are also considering this, I have been able to truncate the rule now. I am only 3 characters away from 1000 but it is there at the moment. 

 

Thank you in advance,

Ziad

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.