I have “List of Comments” in many Things in my app.
For example an Invoice thing has a list of Comments, a Quote thing has a list of Comments, an Appointment has a list of Comments, etc. You can comment on many things.
Now I want to create a single ‘Reusable Element’ called ‘CommentUI’, which will be a button showing the comment count on that field, clicking it will open a ‘Group Focus’ that shows existing comments and a small form to add a new comment.
I want to use this same (CommentUI) Reusable Element to read and add comments in a RepeatingGroup of Invoices as well as in another RepeatingGroup of Quotes, another RG of Appointments, and so on.
This is to avoid creating and maintaining multiple UIs with multiple workflows to add comments in different places. For simplicity sake I have used the above example Things but I have around 40 fields which are Lists of Comments. They are all just Lists of Comments that I need to add to. But how to refer to a field dynamically within a Reusable Element?
What I tried:
- In an RG of Invoices, I can pass in a List of Comments to the Reusable Element as a custom state, which allows me to display all the comments. But to add a new comment it needs to know the name of the thing and field dynamically (“This Invoice’s Comments”, or “This Appointment’s UserComments”). When creating the Reusable Element, how do I pass this knowledge of which Field to store new comments in?
- Creating all List of Comment fields as Custom States on the Reusable Element, with the intention of keeping only one populated and triggering conditionals (When State is not empty), is not ideal because there would be around 40 such custom states and conditionals)
- I tried passing the field name as text to the Reusable Element, but am not able to use text to “dynamically” use the text name to specify a field where to save newly created Comments.