Skip to main content

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:

  1. 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 the WHERE clause. (Is this action named differently or hidden?)
  2. 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 of amounts). 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!

Hi there, ​@egardner! 👋

Sorry to hear of the troubles with that Find Record(s) by Query action. I did some checking and it seems we automatically set ORDER BY and LIMIT for the query and there’s no option to override that. I’d recommend reaching out to our Support team to have a feature requests submitted to allow those ORDER BY and LIMIT values to be overridden, as well as have an option added to prevent the output from being ‘flattened’.  

In the meantime, you could potentially try using Saleforce’s API Request action to run the query instead—I expect it will output the data unflattened but let me know if it doesn’t. Do also want to mention that it’s a bit more advanced as you’d need to reference Salesforce’s API documentation to create the API request, but we have a general guide that should help to get you started: Create an API Request action.

If you give that API Request action a try, keep us updated on how it goes—want to make sure you’re all set! 🙂