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

Question

Question

Field Rules Not Working, But Javascript Isn't Working Either

asked on June 22, 2018 Show version history

I'm trying to do what I thought was something simple!

When the user chooses an item and an action, a specific field (or set of fields) should show up. I've only set up the first three items (Category, Certificate #, and Client) to get them working first with the three actions. In Field Rules, I had each set up as follows:

I set up "DELETED" and "INSERTED" as a table because I want the user to be able to choose to delete more than one item, if so desired. Well, I've come to realize the "UPDATE" gives me no issues because that's consists of a Section and two Single Lines. So, I've come to the conclusion that tables won't work properly (although it does work for one of the three) in Field Rules. Is that true? If so, why? BTW, I did try in javascript ... had the exact same issue!

$(document).ready(function(){

//Allow deselecting of radio buttons
  $('.deselect').on('click', function() {
    $('.radio input').prop('checked', false);
  });

// Hide the appropriate Fields when form first loads
  $('.deleteCategory').hide();
  $('.insertCategory').hide();
  $('.updateCategory').hide();
  $('.deleteCertificateNo').hide();
  $('.insertCertificateNo').hide();
  $('.updateCertificateNo').hide();
  $('.deleteClient').hide();
  $('.insertClient').hide();
  $('.updateClient').hide();

//Based on chosen Item and Action, show/hide data fields
  $(".item input, .action input").change(function(){
    var item = $(".item input:checked").val();
    var action  = $(".action input:checked").val();
//Category
  if (item == "Category" && action == "Delete") {
    $('.deleteCategory').show();
  } else {
    $('.deleteCategory').hide();
  }
  if (item == "Category" && action == "Insert") {
    $('.insertCategory').show();
  } else {
    $('.insertCategory').hide();
  }
  if (item == "Category" && action == "Update") {
    $('.updateCategory').show();
  } else {
    $('.updateCategory').hide();
  }
//Certificate #
  if (item == "Certificate #" && action == "Delete") {
    $('.deleteCertificateNo').show();
  } else {
    $('.deleteCertificateNo').hide();
  }
  if (item == "Certificate #" && action == "Insert") {
    $('.insertCertificateNo').show();
  } else {
    $('.insertCertificateNo').hide();
  }
  if (item == "Certificate #" && action == "Update") {
    $('.updateCertificateNo').show();
  } else {
    $('.updateCertificateNo').hide();
  }
//Client
  if (item == "Client" && action == "Delete") {
    $('.deleteClient').show();
  } else {
    $('.deleteClient').hide();
  }
  if (item == "Client" && action == "Insert") {
    $('.insertClient').show();
  } else {
    $('.insertClient').hide();
  }
  if (item == "Client" && action == "Update") {
    $('.updateClient').show();
  } else {
    $('.updateClient').hide();
  }
  });

})  //close document.ready

 

0 0

Answer

SELECTED ANSWER
replied on June 25, 2018 Show version history

It would have to be hidden by a rule as otherwise it would always display on the form. I believe the "Item 1 Action 3" you have showing in the screenshot of your field rules above is actually the Section and not the field itself.

Note how there's an "Item 1 Action 3" and an "Item 1 Action 3 (Item1Action3)"

The first is the Section, the second is just the field. Since the section is not showing at all times, this suggests your rule hides the section and therefore hides all of the fields within that section.

If the rule was assigned to the field only, then you're Action 3 section headers would always be visible and it wouldn't be hiding your other tables.

0 0

Replies

replied on June 22, 2018 Show version history

What you're trying to do should work. What exact behavior are you seeing?

Can you double check that the rules are referencing the table/collection objects and not the underlying fields/variable(s)?

I just put together a quick form to verify that it works as expected.

-

1 0
replied on June 25, 2018

@████████, thank you, but I believe I'm hitting a known issue that seems to have also come through in Ver. 10.2.1.246 of Forms: https://support.laserfiche.com/Forums.aspx?Link=viewtopic.php%3ft%3d20092%26amp.

replied on June 25, 2018 Show version history

The behavior for single lines (all the Updates) is that it works as expected! The behavior when I use a table (all of the Inserts and Deletes), it'll work on 1 of the 3, but not on all 3. 

I double-checked that the rules are referencing the table/collection objects and not the underlying fields/variable(s).

Due to time constrains, I've decided to change the tables to single value for now. Would have like to have used this form for multiple requests but I'll have to just make it one form per one request, for now.

0 0
replied on June 25, 2018

I'm a bit confused. A field rule targeting a table should hide every row. Were you using a Table or a Collection? And when you say it worked on 1 of the 3, what do you mean exactly? I'm just trying to understand the exact nature of the problem.

0 0
replied on June 25, 2018 Show version history

OK, I was able to recreate the issue in a test form. It works fine when Actions 1 and 2 were one-column tables by themselves. It fails when I added Action 3 as a single-field (with a section header).

I set up the Field Rules and reviewed them all to ensure they're all correct:

Item 1 works fine for all actions:

It's starts failing and not showing proper fields for Items 2 and 3:

That's the behavior I get.

0 0
replied on June 25, 2018 Show version history

That is quite odd. I haven't been able to reproduce the issue.

Your field rules screenshot looks like Sections rather than HTML as it shows the code for HTML elements in field rule drop downs and I'm seeing titles. If those are indeed Sections it would explain things.

The behavior you're seeing makes it look like it is hiding a section that contains the missing tables which in effect overrides your table rules.

This would explain what you are seeing because even if the rule says to show Item 2 Action 2, it wouldn't show up because the Item 2 Action 3 section is hidden and the table would be inside that section along with the single field.

0 0
replied on June 25, 2018

I stand corrected! (I updated the image above.) It is a section, not HTML. It's not hidden by a rule, especially in the test form I created. I didn't put any bells and whistles in the test form.

0 0
SELECTED ANSWER
replied on June 25, 2018 Show version history

It would have to be hidden by a rule as otherwise it would always display on the form. I believe the "Item 1 Action 3" you have showing in the screenshot of your field rules above is actually the Section and not the field itself.

Note how there's an "Item 1 Action 3" and an "Item 1 Action 3 (Item1Action3)"

The first is the Section, the second is just the field. Since the section is not showing at all times, this suggests your rule hides the section and therefore hides all of the fields within that section.

If the rule was assigned to the field only, then you're Action 3 section headers would always be visible and it wouldn't be hiding your other tables.

0 0
replied on June 27, 2018

AH ... now I get what you're saying! You are correct! I can either throw in some sections to block the hiding of the other sections or move the "Updated" sections to the bottom of the form (which is what I did). Silly me! Thanks so much for staying with me on this. It's now working as designed!

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

Sign in to reply to this post.