Hi Community,
I need to get the Top 20 Salesforce Opportunities based on the Amount
field, after filtering them with a WHERE
clause in an initial step.
The Problem:
- Missing Action: My Salesforce connection in Zapier doesn't show a "Run SOQL Query" action (or similar) that accepts
ORDER BY ... LIMIT 20
. I only have "Find Record(s) by Query" which takes just theWHERE
clause. (Is this action named differently or hidden?) - Bad Output Data: The "Find Record(s) by Query" action returns multiple records as "flattened" lists (e.g., one item for all IDs, one for all Amounts).
What Failed:
I tried using a Javascript "Code by Zapier" step to process the flattened output:
- Mapped the flattened fields (
ids
,amounts
,names
, etc.) as inputs. - Tried to split the strings, rebuild an array of objects, sort by
Amount
, and take the top 20. - This failed reliably. The Javascript threw errors because the flattened lists were misaligned (e.g., the list of
ids
had a different length than the list ofamounts
). This happens because Zapier seems to omit values (like null amounts) when creating the lists, breaking the 1:1 record correspondence. We cannot reliably match amounts to the correct IDs.
My Question:
Given that I can't find "Run SOQL Query" and the output from "Find Record(s) by Query" is misaligned and unusable for sorting/reconstruction:
How can I reliably get the Top 20 Opportunities sorted by Amount within Zapier?
Are there any known workarounds for the missing action or the flattened data issue?
Thanks for any insights!