• Instructions to Ask a Question

    Click on the "Ask a Question" button and select the application for which you would like to ask questions.

    We have 5 different products namely - Pabbly Connect, Pabbly Subscription Billing, Pabbly Email Marketing, Pabbly Form Builder, Pabbly Email Verification.

    The turnaround time is 24 hrs (Business Hours - 10.00 AM to 6.00 PM IST, Except Saturday and Sunday). So your kind patience will be highly appreciated!

    🚀🚀Exclusive Discount Offer

    Just in case you're looking for any ongoing offers on Pabbly, you can check the one-time offers listed below. You just need to pay once and use the application forever -
     

    🔥 Pabbly Connect One Time Plan for $249 (🏆Lifetime Access) -  View offer 

    🔥 Pabbly Subscription Billing One Time Plan for $249 (🏆Lifetime Access) - View offer

Random selection of a file on a GDrive

I want to achieve to randomly select a single file in a specific folder on GDrive.
I have issues with multiple problems, here and would kindly ask for hep from the pros on the group.

Problem 1 - knowing how many files are in the folder: When I look at the response that comes back from "Google Drive List Folder Content" command, I do not identify a key that holds the value of the amount of files inside the folder. If that doesn't exist, I guess we have to "count" the files somehow. I tried the iterator, but it needs an array as json and the GDrive responds is not shown as an array. What can I do here? Is there a way to convert the entire GDrive response into an array? Are there other ways to iterate through GDrive files or some other way to count them? Is there a way how to find the highest number seen in any "key"(not "value")?

Next I have to generate a random number between 1 and the prior-step-result-number. This seems easy with RANDBETWEEN(1, [prior-step-result-number]). No need for help.

Problem 2 - selecting the final result: Now, I got the random number and want to use that particular file in the next step of my flow. It is not clear to me how to map that file. As GDrive list response does not give me a key/value pair for a certain file count I need to select the file through it's name or Id, but the number I am looking for is not in any "value" but only in a "key". And ideas how to solve this?

I am very much looking forward to your kind help.
Greetings form Berlin!
 

ArshilAhmad

Moderator
Staff member
Hi @TechVentury,

Google Drive does not provide a specific number(count) for a particular file in a specific folder in 'value'. While you do receive the number of files in the response 'key', it is not possible to use that number to specify a file. Therefore, I am afraid the use case you are describing does not appear to be possible.

Problem 1 - knowing how many files are in the folder: When I look at the response that comes back from "Google Drive List Folder Content" command, I do not identify a key that holds the value of the amount of files inside the folder. If that doesn't exist, I guess we have to "count" the files somehow. I tried the iterator, but it needs an array as json and the GDrive responds is not shown as an array. What can I do here? Is there a way to convert the entire GDrive response into an array? Are there other ways to iterate through GDrive files or some other way to count them? Is there a way how to find the highest number seen in any "key"(not "value")?
To capture responses in the form of JSON, you need to disable the Simple Response.
1705272235523.png


Problem 2 - selecting the final result: Now, I got the random number and want to use that particular file in the next step of my flow. It is not clear to me how to map that file. As GDrive list response does not give me a key/value pair for a certain file count I need to select the file through it's name or Id, but the number I am looking for is not in any "value" but only in a "key". And ideas how to solve this?
As mentioned in my initial statement, Google Drive doesn't give us the file count in 'Value', so getting the count in 'value' is not possible.
 
Top