โ07-29-2024 07:47 AM
I have an Epicor BAQ report I use in Workato that gives me a list of all SKUs in an order and their shipping information
99.9% of the time all the SKUs in an order will be on the same pricebook but on rare occasions 2 SKUs might on pricebook X and 1 SKU on pricebook Y so each record in the BAQ report will have a pricebook field
is there a way in workato to count the number of different prciebooks or do i have to loop through each record to count them?
thanks
Solved! Go to Solution.
โ07-29-2024 08:25 AM
I don't know how your data is structured, but you can use a combination of pluck and uniq to accomplish what you need.
Here's how they work:
list = [
{"book": "a"},
{"book": "a"},
{"book": "b"}
]
books = list.pluck("book")
## outputs ["a","a","b"]
uniqbooks = list.pluck("book").uniq
## outputs ["a","b"]
uniqbooks.size
## outputs 2, the number of items in the array
โ07-29-2024 10:03 AM - edited โ07-29-2024 10:06 AM
You can do it directly from the output of the Epicor action.
Also, just a heads up that will hopefully save you some time...
When you use .pluck you need to refer to a data pill by its "API key", which is the schema key and NOT it's readable label. This usually trips people up when using methods on connector data pills with really long labels, or when the label and the key are completely different.
To see the API key, just hover over the data pill. If you were to pluck the pill below, you would use .pluck("field_1") and not .pluck("blah blah blah...")
I'm mentioning this because you might have to pluck "Price list 2 of price book ID 18 char c" and I would be very surprised if that label was also the API key.
โ09-25-2024 04:54 PM - edited โ09-25-2024 04:54 PM
When data is missing, it should be missing in a few different ways:
If the key is always present and a blank value is "", then this will work!
โ09-25-2024 04:05 AM
how would pluck be used to see if there were any blank/empty fields?
was thinking something like this:
["value"].pluck('PriceLstParts_SfPriceBookEntryId18Char_c').count("") > 0
โ09-25-2024 04:54 PM - edited โ09-25-2024 04:54 PM
When data is missing, it should be missing in a few different ways:
If the key is always present and a blank value is "", then this will work!
โ09-26-2024 06:50 AM
got twisted around and needed to add a null option so this fixed my issue:
["value"].pluck('PriceLstParts_SfPriceBookEntryId18Char_c').count(null) > 0