Help

Re: Zap to pull the first (or random) row from a view?

2223 3
cancel
Showing results for 
Search instead for 
Did you mean: 
Beaudry
4 - Data Explorer
4 - Data Explorer

Is there a way to craft a table/view and a Zap to always pull the first row from that view, when there is no known search key for that view? Alternatively, I’d settle for being able to pull any random row from that view.

It does not appear that Zapier’s Find Record has the ability, since I won’t know the key in advance (these are rows that need to be pulled into a Zap, worked on, then updated so they disappear from the original view, which means the first row will then become something else). And other recommendations on random finds seem to revolve around knowing autonumber ranges etc, which again, I won’t know, since these numbers will change as records disappear from the view.

Anything else anyone can recommend?

7 Replies 7

Welcome to the community, @Beaudry! :grinning_face_with_big_eyes: I don’t do a lot of stuff in Zapier, so this is partly random brainstorming, but here’s one way to approach the problem.

Begin by making a formula field that only has the RECORD_ID() function. In Zapier, set up your trigger step (whatever you want to kick off the zap: webhook, timer, etc.). For the second step, use the Airtable “Find Record” action event, and search that formula field in your desired view for “rec”. Because every record ID begins with that, it will return all record IDs.

The next step would be Code by Zapier, where you would write a short piece of code to randomly select one of the returned record IDs and pass it to the rest of the zap, which would do whatever processing you desire and update the record so that it falls out of the view.

Hi @Justin_Barrett is there a way to get a random record from a row and knowing its id?

Your question doesn’t quite make sense. Records are rows, so “get a random record from a row” is redundant. Did you mean “get a random field from a row”, or “get a random record from a table/view”? Also, if you know the ID then it’s not a random record.

Could you share the bigger picture of your use case and what you’re trying to achieve?

@Justin_Barrett, the bigger picture is: get a random field from a row and when i got it i would like to check (checkbox) of that random field… the trigger will be a button.
The main purpose is get a winner randomly and check it, so he wouldnt be able to win again.

Thanks for the added details. I still think you’re using the wrong terminology. Based on what you described, getting a random field (cell) from a row (record) wouldn’t make sense. I’m guessing you want to get a random record (row) from the table. If I’m correctly interpreting what you described, each row represents someone who has entered to win something, and you want to draw a random person from that list. In that case, you want a random record.

I’m still confused about the part of your original message where you said “knowing its ID”, but it doesn’t sound like that is relevant. If you truly want a random record, then you don’t know its ID ahead of time. Or did you mean that you want to pick a random record and return its ID for later use?

In any case, my next question is this: are you doing this in Zapier (like @Beaudry) or are you doing this directly in Airtable? You said that you’re using a button for a trigger, which sounds like you’re in Airtable. Are you saying that you want a script in the Scripting app that will select (and mark) a randomly-selected record, while displaying the details in the Scripting app’s output?

@Justin_Barrett thanks i didt with zapier…i have another question.
It’s possible to call a webhook from a button but if one record has value"A", call webhook “1” but if the record has “B” value, call webhook “2”? in the same button?

Yes, this could be done by having the button trigger a script in a Scripting app. The script would check the record’s value to see which webhook to call, and make the call using the “fetch” command.