You are viewing limited content. For full access, please sign in.

Question

Question

Read-Only Field Not Showing Value When Sent to Repository

asked on January 31, 2014

We have a form that has several read-only fields and when the form is sent to the repository and saved as a tiff file the read-only fields do not show their value. Is there a way to get them to show? The fields contain dollar amounts that are automatically calculated based on selections on the form, so we do not want to allow the person filling out the form to change those values.

1 0

Answer

APPROVED ANSWER SELECTED ANSWER
replied on January 31, 2014 Show version history

Forms 9.1.1 resolved an issue where Laserfiche Forms was not correctly pre-populating read-only fields with field variables (e.g., current user). 

 

If you are populating read-only fields after the form loads, Forms will not store that value as a security precaution. This is the intended behavior.

 

In some cases it makes sense to work around this issue by using JavaScript to make the field read-only after the form loads. For example, you could try making the field read-only after it has a value as part of your sumtotal function. Add the ro class to the field you want to make read-only.

 

Once the value is populated on the initial form, it will become read-only (because it is part of a code block that runs when the user leaves a table field). But if the form is opened again in a user task or when being saved to the repository, the field won't automatically be read-only (because when the form opens, the user hasn't left that table field yet).

 

$(document).ready(function () {

    $('.cf-table-block').on('blur', 'input', sumtotal);

    function sumtotal() {
        var sum = 0;
        $('td.sum').each(function () {
            var s = 0;
            $(this).find('input').each(function () {
                s += parseNumber($(this).val());
            })
            $(this).find('.subtotal input').val(s);
            sum += s;
        });
        $('.total input').val(sum);

        $('.ro input').attr('readonly', 'True'); //makes the field read only after we give it a value.

    }

    function parseNumber(n) {
        var f = parseFloat(n); //Convert to float number.
        return isNaN(f) ? 0 : f; //treat invalid input as 0;
    }

});

 

4 0
replied on March 17, 2014

Was the read-only field problem addressed in the 9.1.1 forms release?

0 0
replied on March 17, 2014

Yes. This issue is solved in Forms 9.1.1.

0 0
replied on March 17, 2014 Show version history

I just tested it with a form we have that has several read-only fields and there are no values within Forms or when sent to the repository. Running 9.1.1.1517.

0 0
replied on March 18, 2014

Sorry for the misinformation, let me clarify: Forms 9.1.1 fixed an issue where the default value for read-only fields was not being properly saved. This issue has been resolved. As Xiang mentioned in this post, the other behavior where read-only fields are given values after the form loads has not changed. The workaround described in that post still works.

0 0
replied on May 5, 2014

Just to confirm that the issue is still present as described by Eric, but the workaround does work indeed. 

0 0

Replies

replied on January 31, 2014

Are these fields made using a Custom HTML Field or are they fields you are making writable, storing the value, then making read-only?

replied on February 12, 2014

I'm finding this occurrence is also happening when I am performing a field lookup with the results populating read-only fields.  These field values are not visible on the TIFF image when it's sent to the repository, nor are the values retrievable using the "Retrieve Laserfcihe Forms Content" activity in Workflow.

 

How would I make them appear in the TIFF image, and how do I retrieve the values?  Would a similar javascript method apply?

 

How soon will the maintenance patch be released to address this?

0 0
replied on February 12, 2014 Show version history

The same workaround should apply to lookup rules. As long as the lookup rule is matching a value on the form, you should be able to appropriately set the filled field to read-only using javascript.

 

Here's an example. My lookup rule matches a field's value(given the matchedField class) and fills another field (given the filledField value) with some information from the database. Once the user leaves the matched field, the lookup takes action and the code makes the filled field read-only.

$(document).ready(function() {
  $('.matchedField input').blur(function () {
    $('.filledField input').attr('readonly', 'True');
  });
});

The code just illustrates that it is possible, you may need to add to it to exactly fit your particular use-case.

 

Forms 9.1.1 is currently scheduled for release in March.
 

0 0
replied on February 12, 2014 Show version history

Thanks Eric - your code provided makes sense but won't necessarily work in my situation. Here's my use case, and I hope you can steer me in the right javascript direction:

 

Upon logging into an employee form, I have a read-only field being automatically populated by the user account (employee) that has logged in.  This is accomplished with a default value set to {/_currentuser} on the field's properties.  Once this field is populated with the logged-in user, a lookup rule will pull the employee's information from a database and fill out some additional read-only fields.  So essentially, when the employee logs into the form, all of their information is presented so they don't have to enter anything themselves.  And we don't want them to have the ability to change any of their employee information either.

 

The javascript example you provided requires a user to enter a value into a lookup field, and when they leave that field (.blur), it will set the field attributes to read-only.  Since the user will not be entering their own user account into the "matchedField" but instead will have a default value used for the lookup, what would the javascript look like to accomplish setting the rest of the fields to read-only after the lookup?  Is it just a matter of changing the event from .blur to something else that doesn't require the user to manually change the lookup field?

0 0
replied on February 12, 2014

In that case, since the value is being populated automatically, something as simple as this might work (where filledField is the class given to the field being filled in):

 

$(document).ready(function() {
    $('.filledField input').attr('readonly', 'True');
});

 

0 0
replied on February 12, 2014

Thanks Eric, I suppose it was much easier than I was anticipating.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.