Hi All. I was hoping someone can help me understand what I am missing here in terms of how the For Each works in Studio. I have attached a document to help visualize and tell my story. I am pulling the records in using the table_id field as my index/reference and only wanting to process the PENDING status records. For each record it then calls the same table list passing in the table_id to return all the other field values, calls the AD smart object to create the Active Directory records with the fields, then sets the STATUS to COMPLETED. It only runs though for the first record. If I remove the filter/input mapping of PENDING it will process all the records as I would expect it too. What am I missing here? Thanks, Steve
Hi Steven_Rossi,
I'm not sure what could be the issue with for each loop at your end as it seems that every thing is properly set, but i can suggest you, Insted of For Each Loop, Try using traditional method Plan Per Slot No Destinations to loop through the items, as it is much quicker.
Check the below link where it will show how to set the Destination Rule and get the Id from the ActivityInstanceDestination Instance Data.
Regards,
VJay.
Hi Steve,
Try Using Conversion Function, Convert to Number from Context Browser, as activityInstanceDestination Data by default considered as string and you are using it to assign it a number field.
From ContextBrowser-->Function Browser (fx)-->Select ToInteger(Value)-->NAvigate to Workflow Context Browser -- > Select Activity Destination Instance--> Select Instance Data.--> Now asssign this to your SMO input field.
Try this and let me know if it works Steve..
Vijay.
Hi Steve,
Can you just try below steps.
While setting the SmartObject in Destination Rule, Select Order Results by Checkbox and select the ID Field that you are using inside the activty.
See if it works!!
Vijay.
Hi VJay. Sorry to keep being a pest on this. Its still behaving the same way (new snapshot). It seems I am still missing something critical in terms of how its looping through the records. It creates the AD record for the second row and then errors trying to make the same AD record and then never issues the update statement to complete. Also included the package in case its easiar to load and view what I am doing.
Steve
Its ok steve, it happens sometime :-)
K2proj that you have attached doesn't open, i think its missing the Process file, No issues , i would try to setup same scenario in my environment and see whether i could able to replicate your issue.
Mean while i would suggest you to try couple of things.
Check the status Column, Database values has any leading or trailing spaces.
Try Setting the Order Results by to Descending.
1. Remove all events in for loop activity, and add event to log the items to some db to see exactly what are the items that are being looped. Try both cases, with filter and with out filter.
2. Add more rows in data base and do the step 1 to see what exactly are the items that are being looped.
Also could you let me know the K2 version that you are working on
Regards,
Vijay.
Hi VJay. My tests are only showing one record being seen regardless of how I sort it. I am missing something from your web post. If you could post me an example process you have working on your end that you can post for me I would greatly appreciate it. I would certainly prefer to use your suggested method.
However, I did identify what I was doing wrong in my For Each loop or at least what I needed to do to get it working properly. Use the following URL to help:
https://simonatk2.wordpress.com/2016/10/19/how-to-for-each-event/
Instead of adding a filter to only pull PENDING records directly on the For Each (which intuitively I would think should work), I created a Reference to the record so I could work with only the Pending records but then I was missing the Line for records that were not in PENDING status.
Hi Steve,
I tried Replicating your issue but couldn't able to do, as i can get it run in both for loop as well as dynamic destination rule.
Let'd do one thing, if you are ok to have a GoTo Session, let's have it some time today.
you can ping me on linkedin https://www.linkedin.com/in/vijayrangisetty/ when you are ready.
Regards,
VJay.
Thanks ViJay for all your help. Just to inform anyone else reading this post, I ended up having to go with using the For Each (as described previously) for what I needed to do, because if you need to have conditional logic off of an activity you need to use the For Each. The Plan Per Slot No Destinations method as Vijay provided how to do, allows you to loop through the records within the one activity. So for example to loop through records using this method and not a For Each to create AD records looks something like the attached document.
Steve
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.