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

Question

Question

How Can I Override the User Task Going to a Group

asked on September 13, 2017 Show version history

The user filling out the form has the ability to choose a name from a drop-down list or leave it blank (where the task will go to a Team). The issue is that when the user choses an individual, the user task still goes to the Team. How can I override the Team emails and have it go directly to a member of that team?

Everything is working except the email at the user task level. In the example below, all emails should have gone to me but the Structural email should go to the Structural Team.

Thoughts?

0 0

Answer

SELECTED ANSWER
replied on September 14, 2017 Show version history

Hi Gloria,

You'll need a team.findTeamMembersByUserName() or team.findTeamMembersByDisplayName() when setting the "assignedTo" variable otherwise it is just a text string and the code is looking for a user object.

Try this,

var assignedTo, userName;

userName = $util.getValue('draftingUsername');
assignedTo = team.findTeamMembersByUserName(userName);

if(Object.keys(assignedTo).length > 0)
    $result = assignedTo;
else
    $result = team.getAllMembers();

This code will try and find a user in the team matching the "draftingUsername" and if found it will assign to that person, if not, it will assign to the entire team.

The nice thing about this configuration is that an invalid username will cause it to just go to the entire team instead of generating an error.

NOTE: Also, make sure the input value matches the username exactly. For example, if your user shows up as "domain\jdoe" when searching to add them to a task, then "jdoe" will not work because it is incomplete.

1 0

Replies

replied on September 13, 2017 Show version history

Hi Gloria, I had a similar question and it seems that the most practical solution for us was to have two User Tasks, one with the Team assignment and the other with the individual assignments. 

First you would use a Gateway to route the appropriate User Task, where if it's empty it would route to the Team.

Here is the post where Tri Pham assisted us: https://answers.laserfiche.com/questions/126921/Bypassing-the-Assign-to-Me-setting-of-a-User-Task-when-a-team-only-has-1-person#126940

Gateway.png
Gateway.png (15.61 KB)
0 0
replied on September 13, 2017

I had seen this but couldn't find it again. Thank you for responding so quickly!

0 0
replied on September 13, 2017 Show version history

Gloria,

Are the user-entered recipients also part of the Team? If so, you could use JavaScript filters on the Team and keep it all in one user task.

This page provides some good examples.

For example, if the field is blank, assign to the entire team, else, assign to the designated individual.

1 0
replied on September 13, 2017

Yes, they are. I've managed to set up the drop-downs to only show the members of each team. I'll try this tomorrow! Thanks again.

0 0
replied on September 14, 2017 Show version history

OK, so I'm getting an error "The JavaScript filter contained an error: "" [LFF6010-InvalidJavaScriptFilter]". Here's the filter I'm trying to use:

var assignedTo;
assignedTo=$util.getValue('draftingUsername');
if (Object.keys(assignedTo).length == 0)
$result=team.getAllMembers();
else
$result=assignedTo;

I didn't know if I needed the username or display name here? I get an error either way.

0 0
SELECTED ANSWER
replied on September 14, 2017 Show version history

Hi Gloria,

You'll need a team.findTeamMembersByUserName() or team.findTeamMembersByDisplayName() when setting the "assignedTo" variable otherwise it is just a text string and the code is looking for a user object.

Try this,

var assignedTo, userName;

userName = $util.getValue('draftingUsername');
assignedTo = team.findTeamMembersByUserName(userName);

if(Object.keys(assignedTo).length > 0)
    $result = assignedTo;
else
    $result = team.getAllMembers();

This code will try and find a user in the team matching the "draftingUsername" and if found it will assign to that person, if not, it will assign to the entire team.

The nice thing about this configuration is that an invalid username will cause it to just go to the entire team instead of generating an error.

NOTE: Also, make sure the input value matches the username exactly. For example, if your user shows up as "domain\jdoe" when searching to add them to a task, then "jdoe" will not work because it is incomplete.

1 0
replied on September 14, 2017 Show version history

UPDATE:

Almost AWESOME! Jason and Raul have been incredibly helpful! It finally worked ... the test was successful ... it found me with domain\username. However, when I ran through the process, it still assigned to the team, and not me.

I think you meant to assign to have the first result be userName and not assignedTo. So the correct statement should be:

var assignedTo, userName;

userName = $util.getValue('draftingUsername');
assignedTo = team.findTeamMembersByUserName(userName);

if(Object.keys(assignedTo).length > 0)
    $result = userName;
else
    $result = team.getAllMembers();

Going to try it out now!

And, you are correct, if I get a bogus username, it will assign to the team ... such a bonus!!!! Thanks again.

0 0
replied on September 14, 2017 Show version history

Gloria, the code will not work with just "userName" in that field because $result is looking for a team member object, not a username.

If you try and pass the "userName" variable to $result, it will fail because it is not an object and $result does not apply directly to the username, it filters the team array.

If it isn't working correctly in practice but worked in script testing, make sure the value being passed in by the form is actually matching the value you tested.

UPDATE: Check the process variables for the instances that did not work as expected and see what values it has for userName.

0 0
replied on September 14, 2017

I have a little work to do. Turns out, my lookups are no longer populating the username fields. Let me get that working again and I'll try to first JavaScript you provided. Will let you know how it goes.

0 0
replied on September 14, 2017

If you're using hidden fields, also make sure you have it set to "Save" the data. Hidden fields default to "Ignore" meaning it will show up on the form, but it will be lost on submission and will be empty when it gets to the task assignment.

0 0
replied on September 14, 2017 Show version history

That's true for Field Rules, but not Lookup Rule ... unless I'm missing something. I believe the issue is the new view that was created. It gives me the display name just fine, but isn't providing the username from that view. Getting our IS folks to review for me.

Update: My fault! Was filling in display name but forgot to also fill username. LOL! Trying this one more time.

0 0
replied on September 14, 2017

The issue is more about what happens after the form is submitted regardless of whether or not lookups are involved.

For example, if you populate a hidden field (even with a lookup) and the field rule is set to ignore the data, I'm pretty sure it will discard the values upon submission.

The easiest way to check will be to look at the process variables once your view/lookup is working correctly again.

0 0
replied on September 14, 2017

OK, fixed my lookups (my username fields are now getting filled) and changed five user tasks to the first recommended javascript Jason gave me .... and ... drum roll, please ...

It finally worked IN PRACTICE. I can't thank you enough for sticking this out with me. Without you having me look at the variables, I would never have realized my mistake with the new lookups against the new TeamView we created. PHEW! Glad that one is behind me.

0 0
replied on September 14, 2017

Glad to hear it is working!

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

Sign in to reply to this post.