Hello,
I created an infopath process. I am obtaining my destination dynamically from the form( repeating section where the user have the option of sending the next activity to multiple users and their values are domain usernames) and I can have more than one destination from the same form. My problem is, how can I send this infopath activity to more than one destination and being able to take the input from each one of them.
What is happening is the first destination user opens the form has the submit button while the rest dont have that submit option.
How can i have this work properly????
thanks,
Page 1 / 1
Normally, this functionality is fairly simple with the use of multiple slots, activity datafields and a succeeding rule, and if you were using K2ROM or Smartforms for your client event that would be pretty much all required.
When using the InfoPath client event, however, things become a little more complicated. You need to understand what happens in the InfoPath client event first.
You will notice that the Activity will have an XML datafield K2InfoPathSchema that looks exactly like the one in Process data. The reason is that each destination user will get their own copy of the infopath form which is populated with the process data. On the succeeding rule for the activity, this activity data is copied to the process data again.
Depending on the settings you selected in the Client event template, K2 will either create a copy of the infopath form for each destination user (for example if 'Specify name of temporary file' was not selected or you are assigning a unique name for the temp file for each destination). If you specified a file name which is not unique for each destination, each destination user's file will be overwritten with the next user's file and effectively only the last user that was added to the destinations will see the 'submit' button - I suspect this is what is happening in your case. In order to prevent this, you need to deselect the 'enable submit button on task pane only for destination user' in the client event template.
But wait, there's more!
You need to be careful with the activity data being copied back to process level on the succeeding rule, because you may see that only the last user's input appears in the process data, because their data overwrote the previous user's input. Have a look at the succeeding rule on the activity to see what happens there - switch to 'use code' and click 'edit code' to view the code. You may need to add a server event after the client event or add some code in the succeeding rule in order to aggregate data for multiple users.
So if you want to have multiple slots for an InfoPath activity, you need to:
1) ensure that there is a slot for every destination or set the number of slots required
2) ensure that the temp file created has a unique name for every destination
3) decide how you want to handle aggregation of input from the users
4) modify the succeeding rule as required to only expire the activity once the required number of inputs has been reached. In this example, I only expire the activity once all the slots are complete:
Hope this helps
Regards
Neil
When using the InfoPath client event, however, things become a little more complicated. You need to understand what happens in the InfoPath client event first.
You will notice that the Activity will have an XML datafield K2InfoPathSchema that looks exactly like the one in Process data. The reason is that each destination user will get their own copy of the infopath form which is populated with the process data. On the succeeding rule for the activity, this activity data is copied to the process data again.
Depending on the settings you selected in the Client event template, K2 will either create a copy of the infopath form for each destination user (for example if 'Specify name of temporary file' was not selected or you are assigning a unique name for the temp file for each destination). If you specified a file name which is not unique for each destination, each destination user's file will be overwritten with the next user's file and effectively only the last user that was added to the destinations will see the 'submit' button - I suspect this is what is happening in your case. In order to prevent this, you need to deselect the 'enable submit button on task pane only for destination user' in the client event template.
But wait, there's more!
You need to be careful with the activity data being copied back to process level on the succeeding rule, because you may see that only the last user's input appears in the process data, because their data overwrote the previous user's input. Have a look at the succeeding rule on the activity to see what happens there - switch to 'use code' and click 'edit code' to view the code. You may need to add a server event after the client event or add some code in the succeeding rule in order to aggregate data for multiple users.
So if you want to have multiple slots for an InfoPath activity, you need to:
1) ensure that there is a slot for every destination or set the number of slots required
2) ensure that the temp file created has a unique name for every destination
3) decide how you want to handle aggregation of input from the users
4) modify the succeeding rule as required to only expire the activity once the required number of inputs has been reached. In this example, I only expire the activity once all the slots are complete:
public void Main(ref SourceCode.KO.SucceedingRuleContext K2) {
//modified default code to only set SuceedingRule = true when all slots have completed
//get the count of slots
int i = K2.ActivityInstance.Slots;
int j = 0;
foreach(SourceCode.KO.ActivityInstanceDestination oActivityInstanceDest in K2.ActivityInstance.Destinations)
{
if(oActivityInstanceDest.Status.ToString().ToUpper() == "COMPLETED")
{
j += 1;
}
}
if (i == j)
{
K2.SucceedingRule = true;
}
else
{
K2.SucceedingRule = false;
}
if(K2.SucceedingRule == true)
{
DeleteTaskItems(K2,true);
DeleteTempIPFile(K2,true);
}
else
{
DeleteTaskItems(K2,false);
DeleteTempIPFile(K2,false);
}
CopyActInstDataToProcData(K2);
}
Hope this helps
Regards
Neil
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.