Action Button Info

I couldn’t find a public example, so created one here: Student Grades - Grist.

The idea is that you want to record exam grades for students. Select the first exam in the top-left table, and you’ll see the grades for it. If you select another exam, you’ll see that there isn’t a record for each student’s grade yet. You can type in as many new records as you have students (selecting a different student reference for each, and entering the corresponding grade). But the ActionButton widget allows you to create those records with one click, so that you only need to enter the grade for each.

For reference, the formula to create that ActionButton logic is:

actions = []
existing_grades_students = set(Exam_Grades.lookupRecords(Exam=$id).Student)
for s in Students.all:
  if s not in existing_grades_students:
    actions.append(["AddRecord", "Exam_Grades", None, {
      "Exam": $id,
      "Student": s.id,
      "Grade": None
    }])
return {
  "button": "Add {} records".format(len(actions)),
  "description": 'Add "{}" records for {} students'.format($Exam, len(actions)),
  "actions": actions,
}
6 Likes