Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Required field is visible but the parent object is hidden, how to get around this situation?

tarekahf
Level 8
Level 8

We have developed required field custom validation logic, that will loop over list of required fields, one at a time, check if field is empty or null, then it will highlight the field, and raise validation error, one error for all fields that are not filled.

The problem is that the field is marked as required, and the parent subform or object is hidden, due to a bug for example.

How we can get around this issue?

One way it to display the list of empty fields in a subform along with the Required Field Validation Error.

But, how we can jump to the field (using setFocus) if the parent object is hidden?

Is there way to find out if the parent, or any ancestor is hidden, then force to make it visible?

Anyone knows if this issue has been addressed before?

Thanks,

Tarek

1 Accepted Solution
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi Tarek,

I did a form that had a repeatable collapsible block (Site locations in my case),  so when an error was detected I had to make the site visible before navigating to the field.  The errors were in a listbox and the click code, would check for the field being visible, if not it would work up the structure looking for a script object with a makeVisible function in it.  Is that like your situation?

          var targetObject = xfa.resolveNode(targetSOM.value);                       // Use the xfa.layout.page method to determine if the field is hidden as it maybe a parent subform
           // that has the presence set to "hidden".          
           var pageNumber = 0;
           if (targetObject !== null)
           {               
                if (targetObject.className === "exclGroup")
                {
                     // xfa.layout.page does not work with an exclGroup object
                     pageNumber = xfa.layout.page(targetObject.resolveNode("#field"));
                }
                else                {
                     pageNumber = xfa.layout.page(targetObject);
                }
                if (pageNumber === 0)
                {
                     for (var formObject = targetObject; formObject.parent !== null; formObject = formObject.parent)
                     {
                          var scriptObject = formObject.resolveNode("#variables.script");
                          if (scriptObject !== null && scriptObject.hasOwnProperty("makeVisible"))
                          { 
                               scriptObject.makeVisible();
                               break;
                          }
                     }
                }
                xfa.host.currentPage = pageNumber - 1; // This stops the exit event firing on the target object
                xfa.host.setFocus(targetObject);
           }

I used the xfa.layout.page() method to work out if the object was visible and "for (var formObject = targetObject; formObject.parent !== null; formObject = formObject.parent)" works its way up the structure.  The makeVisible function would then call the click event on the expand/collapse button.

function makeVisible()
{
      if (SiteHeader.Buttons.Expand.caption.value.text.value == "+")
      {
           SiteHeader.Buttons.Expand.execEvent("click");
      }
}

There are probably easier ways but this was a general solution which left the hide/show logic in the object that was hidden.

Regards

Bruce

View solution in original post

2 Replies
Magus069
Level 10
Level 10

Hi there,

I guess your best bet would be verifying each parents' visibility when focusing on an object and make sure they are visible.

_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi Tarek,

I did a form that had a repeatable collapsible block (Site locations in my case),  so when an error was detected I had to make the site visible before navigating to the field.  The errors were in a listbox and the click code, would check for the field being visible, if not it would work up the structure looking for a script object with a makeVisible function in it.  Is that like your situation?

          var targetObject = xfa.resolveNode(targetSOM.value);                       // Use the xfa.layout.page method to determine if the field is hidden as it maybe a parent subform
           // that has the presence set to "hidden".          
           var pageNumber = 0;
           if (targetObject !== null)
           {               
                if (targetObject.className === "exclGroup")
                {
                     // xfa.layout.page does not work with an exclGroup object
                     pageNumber = xfa.layout.page(targetObject.resolveNode("#field"));
                }
                else                {
                     pageNumber = xfa.layout.page(targetObject);
                }
                if (pageNumber === 0)
                {
                     for (var formObject = targetObject; formObject.parent !== null; formObject = formObject.parent)
                     {
                          var scriptObject = formObject.resolveNode("#variables.script");
                          if (scriptObject !== null && scriptObject.hasOwnProperty("makeVisible"))
                          { 
                               scriptObject.makeVisible();
                               break;
                          }
                     }
                }
                xfa.host.currentPage = pageNumber - 1; // This stops the exit event firing on the target object
                xfa.host.setFocus(targetObject);
           }

I used the xfa.layout.page() method to work out if the object was visible and "for (var formObject = targetObject; formObject.parent !== null; formObject = formObject.parent)" works its way up the structure.  The makeVisible function would then call the click event on the expand/collapse button.

function makeVisible()
{
      if (SiteHeader.Buttons.Expand.caption.value.text.value == "+")
      {
           SiteHeader.Buttons.Expand.execEvent("click");
      }
}

There are probably easier ways but this was a general solution which left the hide/show logic in the object that was hidden.

Regards

Bruce

View solution in original post