Help with storing data from a checklist

Good morning,
My student created this to do list and was wondering if there is anyway to store the data collected. Could anyone point me in the right direction? I’m thinking data tables or variables but not sure what the most efficient way to do it is.

Thanks in advance for any help!

Sincerely,
Johnna Costanza

Variables are used for temporarily storing data. Data Tables are used for storing data in between sessions. I’m assuming data tables are what you want to use.

For saving and loading checklist data, I would use the getUserId() function. That way, you can have it save to that user’s account.

Here’s an example of saving data using a “Save” button with the ID “saveButton”:

onEvent("saveButton", "click", function () {
  var _tmp = {
    check1: getProperty("checkbox1", "checked"),
    text1: getText("text_input1"),
    check2: getProperty("checkbox2", "checked"),
    text2: getText("text_input2"),
    check3: getProperty("checkbox3", "checked"),
    text3: getText("text_input3"),
    check4: getProperty("checkbox4", "checked"),
    text4: getText("text_input4"),
    check5: getProperty("checkbox5", "checked"),
    text5: getText("text_input5"),
    check6: getProperty("checkbox6", "checked"),
    text6: getText("text_input6"),
    check7: getProperty("checkbox7", "checked"),
    text7: getText("text_input7"),
    check8: getProperty("checkbox8", "checked"),
    text8: getText("text_input8"),
    check9: getProperty("checkbox9", "checked"),
    text9: getText("text_input9"),
    check10: getProperty("checkbox10", "checked"),
    text10: getText("text_input10"),
    check11: getProperty("checkbox11", "checked"),
    text11: getText("text_input11"),
    check12: getProperty("checkbox12", "checked"),
    text12: getText("text_input12"),
    check13: getProperty("checkbox13", "checked"),
    text13: getText("text_input13"),
    check14: getProperty("checkbox14", "checked"),
    text14: getText("text_input14"),
  };
  readRecords("SavedData", {userid: getUserId()}, function (rec) {
    _tmp.userid = getUserId();
    if (rec.length > 0) {
      _tmp.id = rec[0].id;
      updateRecord("SavedData", _tmp, function () {
        console.log("Saved");
      });
    } else {
      createRecord("SavedData", _tmp, function () {
        console.log("Saved");
      });
    }
  });
});

You’ll need to make a table called “SavedData” for this to work.

And for it to load your checklist, you can use this:

readRecords("SavedData", {userid: getUserId()}, function (rec) {
  if (rec.length > 0) {
    setProperty("checkbox1", rec[0].check1);
    setText("text_input1", rec[0].text1);
    setProperty("checkbox2", rec[0].check2);
    setText("text_input2", rec[0].text2);
    setProperty("checkbox3", rec[0].check3);
    setText("text_input3", rec[0].text3);
    setProperty("checkbox4", rec[0].check4);
    setText("text_input4", rec[0].text4);
    setProperty("checkbox5", rec[0].check5);
    setText("text_input5", rec[0].text5);
    setProperty("checkbox6", rec[0].check6);
    setText("text_input6", rec[0].text6);
    setProperty("checkbox7", rec[0].check7);
    setText("text_input7", rec[0].text7);
    setProperty("checkbox8", rec[0].check8);
    setText("text_input8", rec[0].text8);
    setProperty("checkbox9", rec[0].check9);
    setText("text_input9", rec[0].text9);
    setProperty("checkbox10", rec[0].check10);
    setText("text_input10", rec[0].text10);
    setProperty("checkbox11", rec[0].check11);
    setText("text_input11", rec[0].text11);
    setProperty("checkbox12", rec[0].check12);
    setText("text_input12", rec[0].text12);
    setProperty("checkbox13", rec[0].check13);
    setText("text_input13", rec[0].text13);
    setProperty("checkbox14", rec[0].check14);
    setText("text_input14", rec[0].text14);
    console.log("Loaded");
  } else {
    console.log("No data to load");
  }
});

Sure, it’s a lot of code, but that’s what happens when you have 28 elements for a checklist.

Thank you very much. I may have the student try this on a smaller scale to ensure they understand the logic. Much appreciated.