How can we use a UserAction with a loop ?

 7 Replies
 1 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
Accentia ME
Basic Member Send Private Message
Posts: 13
Basic Member

Hi every body,
 
So I'm a beginer on PFI and i’m trying to develop a flow where i get users ID from a table (with sql query), and i set each one in a User Action (via a variable). but when i run it i get the "read timed out" error.
And when i read the PFI developpers guide, i discovered that it's not recommanded to put a usee action into a loop. so i hope that you show me other solutions to do this.

Thank you !!

Bob Canham
Veteran Member Send Private Message
Posts: 217
Veteran Member
Are you trying to do this as an escalation? Or use the SQL query to get a list of users to add to a single user action?

If you're trying to do an escalation, then you would query the user for the first try, and then on the failure of the User action route it back to the query to request the next level.

If you're creating a list of employees for a single User Action, then you would want to put an assign node inside the SQL Query loop to accumulate the user list [code] userlist=userlist + "," Query_Response [/code]. Then you take your userlist variable and put it in the User Action outside the loop.
Accentia ME
Basic Member Send Private Message
Posts: 13
Basic Member
Thanks for your response,

I want to send an approval task to the first user i get from my table, and when he approves the task i get the second approver and i'll send him the second task...etc

So to do this, i put my user action into an sql query loop, like you said but i get the "read timed out" error after approving the first task.
Woozy
Veteran Member Send Private Message
Posts: 709
Veteran Member
Hmmm - I could be wrong, but I don't think this would work the way you are describing it, where you are putting the UserAction within a SQL loop.

When the flow hits a UserAction, the flow is "dehydrated" (BizTalk term) meaning that the flow variable values are saved, the flow is stopped, and it waits for the user to take action. When this happens any variables that haven't been persisted by assigning to a Start variable will disappear - this includes node-related variables. When the user takes action the flow will attempt to start again after the UserAction, but the flow will error because it won't know how to continue the SQL loop that was interrupted.

Instead, you will need to loop through your SQL query and save the return variables somehow (maybe a csv string as Bob suggested). After the csv is saved, then you would need to chomp off the first value from the csv string and pass it into the UserAction. After that user takes action, you'd then chomp off the next value and so on.

It sounds like maybe you are just "playing around" to see how it works. If you are actually trying to solve a business problem then maybe there is a better approach, so you might want to provide more details and see if we can find a better solution.

Good Luck.
Kelly Meade
J. R. Simplot Company
Boise, ID
David Williams
Veteran Member Send Private Message
Posts: 1127
Veteran Member
I think the approach you are going to have to take can be a simple one. You can use your SQL Query to gather the approvers and assign them to an array (comma seperated values within a variable). Capture the length of your array (how many approvers - query record count) and assign that to a counter variable. Assign the oCatValue or Task or whatever for your first approver and go to your UserAction. Once they approve, check to see if your array has another record or not. If it does (Branch) back to where you update the oCatValue and go back into your UserAction.

Keept doing this until your array doesn't have any more approvers and them move on to your next Task, etc.
David Williams
Accentia ME
Basic Member Send Private Message
Posts: 13
Basic Member
Thanx all for your help!
How can i get values from the csv variables without using data iterator node ?
Because with data iterator, i get some issue.
David Williams
Veteran Member Send Private Message
Posts: 1127
Veteran Member
Use a function like this in an Assign node:

approverList is your comma seperated approver variable from your SQL Query
thisApprover is your current approver variable value
counterVariable is the current count of approver (JavaScript begins with 0 as the first record)

var ary=new Array();ary=approverList.split(",");thisApprover=ary[counterVariable]
David Williams
Accentia ME
Basic Member Send Private Message
Posts: 13
Basic Member
Thanx a lot David ! finally i can run my flow successfully now