Passing a Field to a Reusable Element

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:

  1. 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?
  2. 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)
  3. 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.
1 Like

Maybe you could use the url path? Or a parameter to tell which thing youre on and where to save it

Hi @pranab why not use the “+ add new property” button on the reusable to add a comment (list) property on the reusable element. This allows you to add multiple properties on your reusable element.

You can also add invoice property (type = invoice) , appointment property (type = appointment) and quote property (type = quote) (which would pass in the parent invoice or parent appointment or parent quote into those field respectively) Also ensure that they are optional since only one will be filled out of these 3 properties at every point in time.

When creating a new comment, you can either check which of these 3 properties is not empty so as to know who the comment belong to. Or you can further introduce a “Type” property (can be an option set with options invoice, appointment and quote) so you can add this property to every comment reusable element, so you can easily identify who the comment belongs to.