How can I create checklists in Appfarm? I want tasks that are predefined (the user does not need to enter them), and that you can check off when they are completed.
As far as I understand, you want someone (for instance an admin) to create a predefined set of tasks, and then let the users read that task and check complete. Do I understand you correctly?
To solve this, you should create two different object classes in the database: “Todo Item Template” and “Todo Item”. The “Todo Item Template” should have a property “Name”, while “Todo Item” should have a property referencing “User”, a property referencing “Todo Item Template”, and a boolean property “Done”.
Only admins should be able to edit the “Todo Iten Template”, for instance from a designated Admin application. Then, in the end-user application, whenever a user logs into the application, “On app load” you should loop through all the objects in the “Todo Item Template” and create new “Todo Item” objects with reference to the template and logged-in user. You may then list all the “Todo Item” objects related to the current user, and let the user toggle the “Done” property.
You may find an example of a Todo application in the Farmer’s Market. However, it does not have a template-setup like the one described above.
Thank you for your reply! I have one question - if you create new “Todo Item” objects every time the app loads, won’t we lose our information between every use of the app? For instance, when users log into the app, can they see what tasks they marked as done the last time they used the app?
Yes, that is correct. So inside the foreach-loop in the “On app load” action, you’ll need an if-node to check if there already exists a “Todo Item” object with a reference to the “Todo Item Template” in context.
Great, thank you!
Then I have one more question. I want the tasks to be linked to object class project and not user, so I changed the property “User” to “Project” in “Todo Item”. How can I create “Todo Item” objects for each project in the “On app load” action?
You can do that by adding a new data source “Projects”. Then, inside the foreach looping “Todo Item Template", you can add another foreach that loops through “Projects”. Make sure to alter the if-condition we discussed above to also check for references to the "Projects (in context). Lastly, when creating the new “Todo Item” object, add a reference to “Projects (object in context)”.
However, I reckon that all users might not have access to all “Projects”, or might not open them all each time they use the app? In that case, you should not run this action “On App Load”. It is better practice to run the action when a specific Project is opened, i.e. “On Click” on a specific project (which opens a Project Details view). In such a case, you may remove the foreach that loops through “Projects”, as it already has an object in context (the clicked Project).