Skip to main content

Hi,

 

I have a workflow developed in 4.6.11 that is using a FOR-EACH loop.  The source of my list is a smart object list method that is returning a list of people.  When I test out the smart object it returns the right number of records (32 for example).  However the FOR-EACH loop only processes 16 records.  In each case it only processes half of  the records it should have read.  It always processes the odd number records (1, 3, 5 etc...). 

 

The FOR-EACH wizard generated the outcomes and the reference item that contains my single field.

 

I added a data transfer event to count the number of records that should be returned by the smart object call and turned on the audit for the index data field.  Even though the count  field was 32 records, the index only incremented to 16. 

 

 

Has anyone else seen this issue or have any idea what could be causing it to act this way?

 

I would appreciate any adivce you can provide.

 

Thanks

Scott

Dear ,

 

Im tryin to understand ur problem , so its that u got 32 records in ur DB table ? and the list is only showing 16 of them ?? the odd ID's only ?

 

Best regards .


When I smoke test the smart object, it returns 32 records from the database.  The count function I did in the workflow also returned a count of 32 records.  So it appears that the smart object is working correctly.

 

It appears the problem is in the FOR_EACH activity.  The reference item has a single field in it.  But it almost seems like the activity thinks the reference item has 2 fields instead of one.  In other words records 1 and 2 are being loaded into instance 1 of the reference item, records 3 and 4 are being loaded into instance 2.

 

Example smart object returns:

101

102

103

104

 

 

The next item outcome of the for_each activity is executed with 101 and 103. 

 

If I run the workflow a second time the smart object with return 102 and 104 because records 101 and 103 have now been processed.  On that run of the workflow the next item outcome processes number 102 only.

 

Does that help?

 

Thanks

Scott   


I have been doing some additional debugging of the process.  It looks like I am getting some type of error in the next item activity.  My event has a data transfer event and a smart object event to read some data.  It then calls a smart object to insert a record into a sql server table and starts up an IPC event.

 

When just the data transfer and smart object read activities are run the process works as expected.  When I add the create and ipc back in, the problem starts up again. 

 

Has anyone encountered a conflict with a create and IPC?

 

Thanks

Scott


Just posting an update on this issue. 

 

It seems like the FOR_EACH loop has a problem anytime you have an update event.  I set the process up to just insert records without executing the IPC event and it processed every other record in my list.  I then removed the insert and added in just the IPC event.  Once again it processed every other record.  Finally I removed both the IPC event and smart object create call.  That left just the smart object read event and a data transfer event.  At that point, it processed every single record in my list.

 

To work around the problem, I mass inserted my SQL server records with a stored procedure.  I then removed the FOR_EACH event and replaced it with a smart object list event reading for the first unprocessed record (record inserted today with a specific field that was null indicating the workflow had not been submitted yet) that I inserted.  I then put a condition on a line to execute the IPC event if a record was found and looped that activity back to the list event.  When no record was found I then went down the no more items path fromt he FOR_EACH event.   


I think this is the problem with for each loop event. Has anybody got this issue resolved. I am working with K2 support on this issue will update the output.


My experience with For Each is mostly in Views/Forms and works great... 

 

I tipically use Unbound Rules to make sure the logic does not overload the existing running Rule and even with Nested For/Loops with 2 Unbound Rules works awesome.

 

You mention you use a Workflow to execute, I'm not sure if actually uses the same classes to perform the For/Loop. Maybe not. and I put a request to let K2 VBuild a Method of the ForEach directly in the SMO. I dont think it exists.

 

So my suggestion is this... what if you try to duplicate the issue running from the List View and/or from a Form that execute For Each on the list.

 

If that works as expected, the question is, do you think could move that logic to the Form instead of the Workflow ?

 

Just some ideas... curious what K2 Suport has to said about this....


 

Here is solution, I have blogged it.

http://spandk2.blogspot.com/2016/06/scenario-in-my-scenario-i-have-up-with.html


Reply