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

Question

Question

Can only some rows of a table be displayed? (based on the rows with their name in them?

asked on October 12, 2022

If I have a form that outlines deficiencies and the person(s) responsible to correct each deficiency, can I make the task assignment only show the rows that they need to see?  ie, Bert only sees his row(s) while he's submitting his comments and not see anyone else's rows?  The number and types of tasks for each person will always be different.

REASON WHY:  The reason I'm considering this is not privacy.  It's the ability to have the Date Completed be unhidden and be required when they click into "Completed".  I can't make the date completed "required" if some of the other people haven't completed their own tasks.  But I can if the others' rows aren't visible... right?

 

Also posted this one earlier today (same form, different question):

https://answers.laserfiche.com/questions/203008/How-to-get-inclusive-gateway-to-assign-to-person-responsible-based-on-an-empty-date-on-the-same-table-row

0 0

Replies

replied on October 14, 2022

I don't think this is exactly possible via the Field Rules, but here's a way to do it via Javascript.

  1. Turn off back-end validation on your form.
  2. Add a custom HTML element to your form.
    • The contents of the field should be:   {/_currentuser_display}
    • The field should have CSS Class of:   currentUser
    • You can hide this field via Field Rules or CSS.
  3. Then your User drop-down field in the table should have CSS Class of:   currentUser
  4. Add the following Javascript to your form:
$(document).ready(function() {
  
  //When the form is loaded, loop through each row of the table and check if the drop-down
  //field with the myTableUser class matches the current user (a custom HTML element with
  //the currentUser class).  Hide any rows in the table where the user name doesn't match.
  var currentUser = $('.currentUser').text();
  $('.myTableUser select').each(function() {
    if($(this).val() != currentUser) {
      $(this).closest('tr').find('*[required]').each(function() {
        $(this).removeClass('required')
        $(this).removeAttr('required');
      });
      $(this).closest('tr').hide();
    }
  });
  
});

 

Without the Javascript, the table has all its rows:

But with the Javascript, only the rows with my name show and are required:

 

Note that the code only runs when the form is loaded, so if I change one of the user drop-downs, it doesn't hide that row immediately.  We can modify the Javascript if that behavior is needed.

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

Sign in to reply to this post.