I have javascript running some calculations on a form. They work fine at runtime when a user is filling it out. They work fine for the approver if "Make form read-only for task participants" is not checked. However if I check that box then the JavaScript calculations run but cannot update their corresponding fields. In looking at the source cod I see that a "$document.read(function()" runs before mine called ConvertFieldsReadonly. It runs after the form is initialized, which allows the fields to be populated but locks the document before my calculations can run. In my JavaScript I am using "$('.ro input').attr('readonly','False');" to set all fields in the .ro class to not be read-only, then running the calculations, updating the corresponding fields, and then setting them back to read-only. What am I missing to have these calculations still run and update their fields during the approval process when the "Make form read-only for task participants" is checked?
Question
Question
Answer
Instead of
$('.ro input').attr('readonly','False');
use
$('.ro input').removeAttr('readonly');
or
$('.ro input').attr('readonly', false);
Replies
If you're updating field values, you need to ensure that those fields are not read-only when the form loads. If Make form read-only for task participants is selected, Forms won't update the form's field values as a security precaution.
Can these calculations run in the initial submission instead of at this approval step?
They do run during the initial portion when the form is submitted but Forms does not appear to save their values. These calculation fields are not set to read-only in the form designer. When the form loads the javascript I have in the document.ready portion a function called sumtotal that sets the calculation fields to not be readonly, runs the calculations, updates the fields, and then sets them back to read only. To the viewer they update accurately. Is there something I am missing that allows those values to be locked in when the form is later viewed as read-only by an approver?
If the fields are not set as read only when their values are populated, they should properly stored those values. Can you upload your process so I can take a look at it? If it doesn't let you upload an .xml file, just change the extension to .txt.
I appreciate your help with this. I've attached the forms javascript and a screenshot of the pertinent portion of the form.
Instead of
$('.ro input').attr('readonly','False');
use
$('.ro input').removeAttr('readonly');
or
$('.ro input').attr('readonly', false);
Thanks a ton. $(
'.ro input'
).removeAttr(
'readonly'
); worked great. I had actually tried that earlier but must of typed it wrong. I appreciate your help in getting this resolved.
You're welcome!