AnsweredAssumed Answered

How do I dynamically set the readOnly attribute for a field property?

Question asked by joeblue on Nov 7, 2016
Latest reply on Dec 20, 2016 by joeblue
I am trying to figure out how to dynamically set the readOnly attribute for several fields in a large form. My process and form are rather complicated, so I'm going to simplify it for this post:

My Users:

My Process:
Step 1: FormCompleter fills out the fields in the form.
Step 2: FormReviewer reviews the form and then indicates their approval/rejection of the form.

Both steps use the same form. In Step 2, I want to set the readOnly attributes to "true" for the form properties that the FormCompleter filled out in Step 1—i.e., in Step 2, the FormReviewer will not be able to edit any of the values entered by the FormCompleter in Step 1.

I believe I can use the formRendered JavaScript event to trigger this action. However, I have no idea how to access the readOnly attribute for a form property in JavaScript in order to change the readOnly value. (technically, I have no idea how to access the readOnly attribute at all because the only place I have seen the readOnly attribute is in the form's JSON file that I exported).

Please Note: Making a separate form for Step 2 using DisplayText and DisplayValue properties is a non-starter for me because my actual process and form can require up to 5 different users that need access to the form, each with different read/write privileges. I've seen this suggested as a solution to a similar problem on the forum, but I do not want to maintain 5 different versions of what is essentially the same form. I'd much rather just dynamically set the readOnly attributes when a user accesses the form.