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

Question

Question

After Sending to Laserfiche Some Hidden Fields are Showing

asked on January 10, 2017

After running my Send to Repository Service Task, which is set to send the form as a TIF file, I'm finding that some (but not all) of my hidden fields are showing in the copy in the repository.

These are fields that are being hidden by Javascript that is running as the form loads.

It seems like the first code that is run is working, those fields are hidden in the repository.

By the second batch of show/hide code that is running isn't showing as hidden in the repository.

I'm not positive, but it feels like the copy in the repository is being created before the form has completed finished processing all of the Javascript.

Has anyone else encountered this issue?  And if so, know how to work around it.

Thank you!

0 0

Answer

SELECTED ANSWER
replied on January 11, 2017

You were right @████████that the issue was related to the fact that the fields are changed when it is in the read-only version.  By painstakingly comparing the "Inspect Page" element of the form in the editable version and the read-only version, and using tricks like alerts and background colors (adding .css('background-color', 'yellow'); to form elements), I was able to eventually (several hours later) narrow down which parts of my Javascript were not running in the read-only version.

Here is the code I was using before - to cycle through all the records in the collection and check for a field value, and if correct hide/show fields as appropriate:

$('.numberBranchesSplit input').each(function() { 
    if ($(this).closest("ul").find('#q83 input').val() != "1") {
        //show and hide fields as appropriate
    }
});

And here's the updated code that works in both the live editable form, and the read-only version that displays in the instance history and in the repository.

$('.numberBranchesSplit').each(function() { 
    if ($(this).closest("ul").find('#q83 input').val() != "1" && $(this).closest("ul").find('#q83').text() != "1") {
        //show and hide fields as appropriate
    }
});

As you can see, I had to make two major changes:

  1. In the Each Loop, I was searching for all '.numberBranchesSplit input' elements, which works in live, but not in read-only.  When I changed it to search for all elements of '.numberBranchesSplit' (dropping the input) it worked in both versions of the form.
  2. When checking the value of the input field, it wasn't recognizing it as an input field once it was read only, so I had to check for the value in two versions of the field.  In the live form, I'm checking the val(), but in the read-only form I'm checking text() instead.

This is now working across the board for me.

Although I was really frustrated that it took me hours to figure out what was what, I am thankful to you for pointing me in the right direction.

4 0

Replies

replied on January 10, 2017 Show version history

I can think of two workarounds.

  1. Use field rules to hide them.  
  2. Make a copy of your form and delete those undesired fields.  In your Save to Repository process, select "Save a form with current process data" and choose the copy.
0 0
replied on January 10, 2017

Unfortunately in this case, I don't think either of those solutions will work.  They are fields in a collection, so my Javascript cycles through all records in the collection and checks the fields to see how they were filled-in on a prior step and chooses to show or hide them as appropriate.  I also have fields where a user can click a button to "add more" triggering additional fields being unhidden.  It's kind of complex for field rules, and (unless something changed) the field rules won't hide the fields anyway, just make them read-only, because I've altered the layout via CSS.

Really, what I need, is the ability to do a table inside a collection - but as I understand it, that isn't possible - which is why I've done this workaround.

Ultimately, it's not showing anything bad with the fields that should have been hidden, but it is a little confusing.  sad

0 0
replied on January 10, 2017

Please check whether the fields are shown when you view the submitted form from the instance history. The form saved to repository is use the same read-only form as show the submitted form and some elements(such as input) are changed to div element on read-only form so your custom JavaScript may not take effect on read-only form

2 0
SELECTED ANSWER
replied on January 11, 2017

You were right @████████that the issue was related to the fact that the fields are changed when it is in the read-only version.  By painstakingly comparing the "Inspect Page" element of the form in the editable version and the read-only version, and using tricks like alerts and background colors (adding .css('background-color', 'yellow'); to form elements), I was able to eventually (several hours later) narrow down which parts of my Javascript were not running in the read-only version.

Here is the code I was using before - to cycle through all the records in the collection and check for a field value, and if correct hide/show fields as appropriate:

$('.numberBranchesSplit input').each(function() { 
    if ($(this).closest("ul").find('#q83 input').val() != "1") {
        //show and hide fields as appropriate
    }
});

And here's the updated code that works in both the live editable form, and the read-only version that displays in the instance history and in the repository.

$('.numberBranchesSplit').each(function() { 
    if ($(this).closest("ul").find('#q83 input').val() != "1" && $(this).closest("ul").find('#q83').text() != "1") {
        //show and hide fields as appropriate
    }
});

As you can see, I had to make two major changes:

  1. In the Each Loop, I was searching for all '.numberBranchesSplit input' elements, which works in live, but not in read-only.  When I changed it to search for all elements of '.numberBranchesSplit' (dropping the input) it worked in both versions of the form.
  2. When checking the value of the input field, it wasn't recognizing it as an input field once it was read only, so I had to check for the value in two versions of the field.  In the live form, I'm checking the val(), but in the read-only form I'm checking text() instead.

This is now working across the board for me.

Although I was really frustrated that it took me hours to figure out what was what, I am thankful to you for pointing me in the right direction.

4 0
replied on June 6, 2017

I'm having a similar issue but I've tried using .text() in addition to .val() without any luck.  What gets me is that I'm using an if/else statement so even if the "if" wasn't evaluating properly it should run the "else" part, and it isn't doing that.

I'm hiding using $('.cssclass').hide(); to hide the fields in question which is working fine in the live version; is there a reason why that wouldn't work in the repository version?  I've also tried having it add a class to those fields that calls this: .fieldhide {display: none !important;} and still no dice.

When I go to the instance history and look at the final read-only version it's all correct; it's only in the repository that the fields are not being hidden.

You are not allowed to follow up in this post.

Sign in to reply to this post.