Build a One-Day Survey & Lottery System with SeaTable Scripts
Learn how to quickly create a questionnaire using SeaTable, automatically collect responses, and run a custom script to randomly select winners, providing a fast, low‑code solution for urgent business needs without a full development cycle.
Form Data Collection
When a business needs a rapid survey and prize draw, a full‑stack implementation can be risky, but many SaaS form services can handle the job. SeaTable is a collaborative online spreadsheet and information management tool that supports rich data types such as files, images, single‑choice, collaborators, and formulas, making it suitable for both data collection and lightweight database needs.
The following steps show how to set up a questionnaire, collect responses, and use a script to pick winning participants.
1. Create the Table and Define Questions
Create a "User Survey" table and add columns for each question, choosing appropriate data types:
"Name" column – Text type for entering names or nicknames.
"Industry" column – Single‑choice type for selecting an industry.
"Task" column – Multi‑choice type for selecting one or more tasks.
"Suggestions" column – Long‑text type for detailed feedback.
2. Create the Form
After configuring the table, click the "Form" button to generate a form. You can customize the form by hiding fields, setting required fields, adding instructions, and configuring access permissions. Once the form is ready, share its link or QR code with participants. Submitted data is automatically aggregated into the "User Survey" table.
Use Script to Select Winners
After collecting survey data, add a sub‑table named "Winning Users" to store the selected winners. Then create a new script in SeaTable, naming it "Lottery Script".
Script Code
const winningTableName = '中奖用户';
const winningColumnName = '姓名';
const alternativeTableName = '问卷调查记录';
const alternativeViewName = '默认视图';
const alternativeColumnName = '您的姓名?';
const winningCount = 5;
const table = base.getTableByName(alternativeTableName);
const view = base.getViewByName(table, alternativeViewName);
const rows = base.getRows(table, view);
const winningTable = base.getTableByName(winningTableName);
for (let i = 0; i < winningCount; i++) {
let index = Math.floor(Math.random() * rows.length);
selectedRow = rows[index];
const selectedUser = selectedRow[alternativeColumnName];
rows.splice(index, 1);
base.addRow(winningTable, {[winningColumnName]: selectedUser});
}Running the script randomly selects five participants and inserts their names into the "Winning Users" table, completing the lottery process.
Conclusion
This case demonstrates how SeaTable's form and scripting capabilities enable rapid data collection and automated winner selection without a full development cycle. For short‑term, urgent requirements, leveraging such low‑code tools can meet business goals while minimizing impact on existing development plans.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
