I have a requirement to query multiple price lists and then compare them and select the lowest price. Once I get the price, I need to report which price list it came from and the price. If all prices return zero, I also need to report that.
I can do all of the above with a lot of Run-If controls. I am trying to prevent that. I would like to use a collection for the returned price but I lose the association between the price and the price list. Has anyone come up with a better way of doing this than using lots of run-ifs?
I don't understand exactly what you're doing here, but it it possible to use two collection variables, one for price and the other for the price list and have them correlated by their position in the collection? Then after you've queried all the lists and loaded all the values you could run a loop through the "price" collection, keeping track of the index to determine that the lowest price occurred at index n and then pull the list name back out of the list collection by using n?
I thought about that but at the time that I asked the question, I was querying all of the lists in parallel and I was worried that if I added the price to a collection, I wouldn't be guaranteed that the price list would be added to another collection at the same index. It is entirely possible that as I was adding a price to a collection, another process would be adding a price list to the other collection at the same time. I didn't see a way to guarantee that they would be added to the collections at the same index. Also, I was planning on sorting by price and I figured that if I sorted the price collection, it would reindex those values and I would lose the relationship integrity with the price list collection.
What I ended up doing is storing the results in different variables and then comparing the variables to each other, taking the lowest price during the compare. It's fairly linear but it works. There are also a lot of Run-If actions.