I would like advice on best practice for setting the visibility of multi-tenant blocks within our Forms.
My only directive is that the implemented solution needs to be simple enough that any form designer should be able to recreate the process without needing assistance from the template designer.
In order to achieve this I have found four ways of completing this task:
Proposed solution A:
1) Create a separate space per from intent.
2) Associate the rules to the space not the forms in the space
Proposed solution B:
1) Custom block saved to the project library that form designers just drag into the form.
2) Corresponding TM script that will set the visibility via xpath in the prefill using a referrer.
xmlDoc.setText("//Internal/InternalFlag", "Internal") or xmlDoc.setText("//Internal/InternalFlag", "External")
(Cant use a datafieled as xmlDoc.setText cant cast from string to boolean)
Proposed solution C:
1) Create a form rule as per the Maestro documentation
- Form rules can be used to drive form behavior at the form level
Then we can then set values of unbound data elements on the data object, e.g.:
data.$usName = false; // Editability preference for name fields
data.$shName = true; // Visibility preference for name fields
Only issue I have found with this is that some developer experience is required to implement.
Proposed solution D:
1) Create a form per intent
- Internal version of the form
- External version of the form
Pro - End users are able to manage this implementation without developer assistance.
Con - Two sets of forms to update
Taking into consideration that the implemented solution needs to be form designer friendly, what would be the best practice method to implement a block of this type?
I would recommend Solution B as it allows you to set the mode (internal/external) of the form on the server side. Fields/Sections reads that mode value to drive the visibility. However, to decouple the visibility rule to read the data.InternalFlag on every field/section, I would recommend you create a JS function that reads the value of the mode and returns true/false which then drives visibility. This way it allows you to have flexibility if you want to enhance that condition with something else and you only have to make a change at one place.
That is great advice using the function to read the value and only making the change in a single space.