Posted: 5 Dec 2019 11:56 EST Last activity: 10 Dec 2019 10:07 EST
What is the correct way to loop through a collection of ambiguously interrogated objects
The question comes from web page that has an anchor tag that repeats down the page. I have the properties UseElementID set to False and UseKeys set to True. I want to get the text for each anchor and add them to a look up table. I have found two methods that work but wanted to know if one is preferred over the other. I have attached screen shots of the two methods as well.
Method 1: Extract a proxy out of the Item port on the List Loop and use the proxy to get each anchor's text.
Method 2: Do not extract a proxy but run the command line through the text property from the Item Yielded port on the loop and loading that text into the lookup table.
Side note on Method 2, I do know that if I connect this differently the text property will show the menu to select None or Key, and selecting None will result in the same text being loaded into the lookup table. Method 2 will only work when that menu on the text property is not visible.
Is there a preferred way to handle this and if so what would be the reasoning for doing it one way vs the other way?
Being a long time user of Pega Robotics/OpenSpan I have my reasons for chossing number 1 (GetClones and extracting a proxy). The reason I would choose this is because it is visually self-explanatory.
GetClones returns and array of objects
You are iterating each object
The output of the ListLoop is that object (i.e. one of the clones)
You extract a proxy to get to the properties of that object
At one point, this was the only way to do that. I personally have not tried option 2 as I am a dinosaur and know what works, however I believe that somewhere along the way our ListLoop was updated to keep the correct key in context and therefore allow option 2 to work. I have seen other automations written this way and they were supposedly working, which is why I have a feeling that it works. Visually though, it looks incorrect as no where in the automation are you ever explicitly defining which object you want (since aClmNum is basically a list and not an individual link without providing a key). If it does ask you to provide a key, then you'd have to get that key from a proxy anyway since None would refer to the first key in the array. If you had to do that, why not just use the proxy?