Choice one item randomly?

I want to fill the choice column randomly using a formula.

I intend to use import random, but don’t know how to put the choice list I defined.

Consider I have a ‘menu’ column and have [pizza, chicken, milk].

And when I make a new cell in the ‘menu’ column

I want it filled with one of the list items randomly.

But I don’t know how to use the list with the random function.

How can I access the choice list data which the column has itself?

Now I make the list by myself and put it into the random function.

But I think there is a better way.

import random

# Fetching the list of items from another table's column 'Item'
items = [item.Item for item in MenuItems.all]

random.choice(items)

it gets a random item from the table “MenuItems”, column “Item”

It updates all random choices every time MENU ITEMS table is changed, so you should maybe use it as a trigger

image
image

1 Like

Thanks! it solved :slight_smile: