I have a script in a spreadsheet:
function chooseIt() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var firstSheet = spreadsheet.getSheets()[0];
var secondSheet = spreadsheet.getSheets()[1];
var randChoice = 2+(Math.floor(Math.random()*8));
var myRange = firstSheet.getRange(randChoice,1);
var choice = myRange.getValue();
var myImage = firstSheet.getRange(randChoice,3);
var myImageData = myImage.getValue();
secondSheet.getRange(2,1).setValue(choice);
secondSheet.getRange(2,3).setValue(myImageData);
}
It in the spreadsheet: WheresLunch - Google Sheets
and the “chooseIt” tab only works occasionally the script is not executed always upon selecting the chooseit button
Link to app: https://daaiz.glideapp.io
any clues how to get the spreadsheet script to always run…OR how to generate a random number in the app…thanks…Sandy
Yeah correct that the whole point is to give the user a random choice from among all available restaurants (the choices)…is there any local (i.e. on the phone or in app) computation possible?
No way to do it within Glides with the current feature set.
If I may make a suggestion. Instead of just a random pic of the computer, from a user standpoint I think it would be more beneficial if they could, drill down so to speak based on type or cost. I’m sure your plan is to add some more information about the restaurants like type (Italian, Asian, etc.) and average costs per meal, maybe using $$$$ to indicate. Then you could add tabs for those categories and sort by those things.
I attempted creating random links/images in https://concepts.glideapp.io/ . The results were mediocre at best. Instead of a script I’m using the RANDBETWEEN. It works, but only regenerates the link on either some schedule I haven’t taken the time to figure out yet or whenever a change is inputted into the sheet. If something changes on the sheet then the link changes, but sometimes the result in the app doesn’t match what’s in the sheet. It’s weird, but kinda works. I was hoping to get it to change every minute to use for affiliate advertising links. Your script is probably a better option and it can be ran on a timed trigger. Just taking a look at your app, I do see the random restaurant changing, so I assume you have something figured out already.