Status: Open
Status: Answered
Status: Closed
Status: Duplicate

Control a field's properties - to toggle the field between Optional and Read Only

Posted Mar 22 by Dean Mueller.

I have a form that a user will open to enter additional info in (say for example after the first quarter of the year has passed).
With that, they can update new fields on the form that are specifically for quarterly updates.
But on the original fields that were provided to them when they entered their Business Plan info, there may be fields they didn't enter data into. I would like to make the fields on the form that are 'empty' to be optional but fields that they did enter data into flipped to be read only so they can't edit previous data but only enter data into fields that they left blank.
How can I do this say when the form loads to sweep through the fields and mark those RO and leave the others option to edit, say in some code or otherwise? Any insight or examples would be greatly appreciated.
Thanks I am using Metastorm Version 9.1

2 Answers

BEST ANSWER: As chosen by the author.

The normal "recommended / supported" MBPM method would be to have two or three fields (one editable/required, one editable/optional and one read only) and display the applicable field as appropriate via "only show when" and applicable checkbox values.

It is possible, though unsupported, to modify field options directly in a client script code. For instance:
document.getElementById("<field>") then setting .disabled (and .style.backgroundColor and .style.borderColor if you want it to truly look like a read only field. This is cumbersome, but is possible. I do not know offhand if the field is set to required in the Designer but your client side script makes it read only if the form will not save if the field is empty even though its "read only" as it may think of it as required still.

BEST ANSWER: As chosen by the author.

Thanks for the reply. Yes, that's the response I got from Metastorm. Have overlapping fields each being either read only or optional. The problem with this form is there are A LOT of fields on the one form (as it was designed to how the Attorneys wanted it - one large page they can scroll up / down to see everything as they edit it. I even get warnings that this form has too many fields. So if I doubled it with read/only fields, it would take FOREVER to load as that takes enough time now.
I just thought if someone knew the script/code on setting the property that drives optional/read only/… then I could do some verification on load to toggle it accordingly based on whether some data existed in it or not.
This is just something they asked if we 'could' do it but not a make/break requirement. We just wanted a way for them to not edit existing fields if they contain data / or change the existing data and only enter data into fields they didn't enter initially. My other thought would be to store all the fields in temporary variables and then compare the data on them submitting. If the field was initially NOT EMPTY and they went to change it, I could reset the data back to it's original state, otherwise leave it. But I guess this all goes back to 'is it really necessary' as we don't even know if they are going to change existing data to begin with.

 You have subscribed and will receive email notifications of updates to this topic. To unsubscribe, uncheck the checkbox.


Related categories

Your answer

To leave an answer, please sign in.