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

Question

Question

Java Script Filter - Always assign to one person, unless they were the previous submitter

asked on May 15, 2020

I am trying to use the javascript filters in Forms 10.4.2.381, and am looking to assign a task always to the supervisor, unless they completed a previous step.  If so, assign it to a different person.

 

The scenario is the Payment Services team has the task assigned to them for processing.  It then goes to another step for verification, assigning again to the Payment Services Team, excluding the person who did the processing, using a filter.  (This part works fine)

 

We're looking to escalate this Verification step to the manager within a certain period of time.  The catch is if the manager had to do the initial processing, we'd like to have it escalate to a different, specified person.  (We'll call them Employee A)

 

Using the following filter, it properly assigns to one or the other.  (The Manager or Employee A)  If either was the processor, but if I have a different person as the processor (Employee B), it returns both the Manager and Employee A. We're looking to have it return the manager only, unless they were the processor.

var Manager = team.findMembersByRole('Payment Services Assistant Manager');
var ProcessedBy = team.findTeamMembersByDisplayName($util.getValue('Processed_By'));
if (Manager = ProcessedBy)
{
	var EscalationTeam = team.findMembersByRole('Internal Funds Transfer Verification Escalation');
	var Exclude = team.findTeamMembersByDisplayName($util.getValue('Processed_By'));
	$result = $util.difference(EscalationTeam, Exclude);
} else {
	$result = Manager;
}

If helpful, the manager is the only person with the role of 'Payment Services Assistant Manager'.  Also, the manager and Employee A are the only two people with the role 'Internal Funds Transfer Verification Escalation'.

 

As for the javascript, it looks like it keeps evaluating the IF condition as true, when it shouldn't, assuming I've done it correct.

 

Thanks

0 0

Replies

replied on May 15, 2020

Hi Evan, this is easy accomplished with Teams and Filtering. You can pick select a Team Role and exclude the Previous Submitter from a step in the process.

If you still want to do it with Javascript, look up the Team Filter Examples in the manual and they show the Javascript Methods you can use for this

To easily get to the part in the manual, under Filter there is a Learn More that takes you to that part of the Manual

replied on May 15, 2020 Show version history

Hi Evan

Where are you identifying who submitted a form at a previous step, as those are the members you need to exclude/include would it not? 

findTaskSubmitters(StepID): Returns the team members who submitted a form on the specified step. If the step ran multiple times in the process, this expression will return a list of all the team members who submitted a form in this step.

excludeTaskSubmitters(StepID); Returns the team members who did not submit a form on the specified step. If the step ran multiple times in the process, this expression will return a list of all the team members who did not submit a form in this step.

0 0
replied on May 15, 2020 Show version history

I'm using a variable from the form completed at the prior Processing step.  On that form is a field that is read only and captures the display name of the current/named user.  The variable name for that is Processed_By.  This business process doesn't loop back or re-use the processing form, so multiple people completing the processing step isn't a concern.

 

(All of our users are named users, using windows credentials)

 

The part I'm getting stuck at is forcing the Verification escalation to the manager unless they happened to be the processor of the previous Processing step.  (I'm trying to use teams and filters to minimize the number of locations that statically assign to people.  Teams are much better for employee changes/turnover)

0 0
replied on May 15, 2020

I have found that if you use the Forms Read Only function, that Javascript may not be able to retrieve that variable. Try turning the Read Only off and see if it works differently. If so, use JS to set the Field to Read Only instead

0 0
replied on May 15, 2020

Except it isn't javascript on the form it self. It is the process designer.

 

It reads the value from the Processed_By just fine when it is the manager or Employee A.  (It will assign exclusively to their counterpart)

 

The problem is it assigns to both when it is processed by someone else, when it should just be the manager. 

0 0
replied on May 15, 2020 Show version history

Hmm, this code you posted just above is different from what's up top, was that just testing?

1 0
replied on May 15, 2020

Ah yes, I was testing other ideas but didn't switch it back for the screen shot.  I was trying to see if the problem was the else condition. I thought that maybe by having it populate the $result value first and then overwrite it with the result of the IF.  But that didn't help.

 

(The screenshot was more for making sure it was clear that I'm working in the process designer, not the form itself.)

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

Sign in to reply to this post.