Expand my Community achievements bar.

SOLVED

Hide Table Sections Based on User Inputs

Avatar

Level 9

I have linked my form below. I am trying to script the "Hide Closed" button. I want to hide all of the instances of the "ActionItemGrp" table sections when the user has entered a date in the "ClosedDate" field. I tried the following script but can not get it to work.

Form1.ButtonsPage.HideClosed::click - (JavaScript, client)

for (var a=0;a<Table1.ActionItemGrp.instanceManager.count;a++){
for (var b=0;b<Table1.ActionItemGrp.all.item(a).Table1.ActionItemGrp.Row5.instanceManager.count;b++) {
  if (Table1.ActionItemGrp.all.item(a).Table1.ActionItemGrp.Row5.all.item(b).ClosedDate.rawValue!==null)
   Table1.ActionItemGrp.all.item(a).presence = "hidden";
}

Link to my file on WeTransfer:  http://we.tl/bmZjwdb52u

Help is apprecaited...

1 Accepted Solution

Avatar

Correct answer by
Level 10

Ah ok.

That's tricky but this script should do it.

for (var t = 0; t < _Table1.count; t += 1) {

          for (var a = 0; a < xfa.resolveNode("Table1[" + t + "]")._ActionItemGrp.count; a += 1) {

                    var aTarget = xfa.resolveNode("Table1[" + t + "].ActionItemGrp[" + a + "]");

                    if (!aTarget.Row5.ClosedDate.isNull) {

                              aTarget.Row3.presence = "hidden";

                              aTarget.Row4.presence = "hidden";

                              aTarget.Row5.presence = "hidden";

                              aTarget.Row6.presence = "hidden";

                    }

          }

}

View solution in original post

12 Replies

Avatar

Level 2

I don't see how this object reference would work:

Table1.ActionItemGrp.all.item(a).Table1.ActionItemGrp.Row5.all.item(b).ClosedDate.rawValue

It appears that you've restarted the hierarchy (Table1) in the middle of an object reference.

Avatar

Level 9

Scott-Mc,

Thanks for your reply. The script example i gave does not work. Can you help me figure it out?

Avatar

Level 9

This does not work either...

Form1.ButtonsPage.HideClosed::click - (JavaScript, client)

for (var a=0;a<Table1._ActionItemGrp.count;a++){

for (var b=0;b<Table1.ActionItemGrp.all.item(a)._Row5.count;b++) {

  if (Table1.ActionItemGrp.all.item(a).Row5.all.item(b).ClosedDate.rawValue!==null)

   Table1.ActionItemGrp.all.item(a).presence="hidden";

}

}

Avatar

Level 10

Hi,

as the element ActionItemGrp is a subform Set you won't be able to contoll its presence only those of its children (row3 etc.).

for (var a = 0; a < Table1._ActionItemGrp.count - 1; a += 1) {

          var aTarget = xfa.resolveNode("Table1.ActionItemGrp[" + a + "]");

          if (!aTarget.Row5.ClosedDate.isNull) {

                    aTarget.Row3.presence = "hidden";

                    aTarget.Row4.presence = "hidden";

                    aTarget.Row5.presence = "hidden";

                    aTarget.Row6.presence = "hidden";

          }

}

To make this work event with only one instance of the ActionItemGrp you have to remove the min occurences in its binding tab.

Hope this helps.

Avatar

Level 9

Even when removing the minimum occurrences, the script will not hide the first occurence. It does hide the others.

Avatar

Level 10

For me it worked.

Share your current form, so I'll will check, what's wrong.

Avatar

Level 10

Hi,

there was a bug in the script I've posted before.

Here's the corrected one.

for (var a = 0; a < Table1._ActionItemGrp.count; a += 1) {

          var aTarget = xfa.resolveNode("Table1.ActionItemGrp[" + a + "]");

          if (!aTarget.Row5.ClosedDate.isNull) {

                    aTarget.Row3.presence = "hidden";

                    aTarget.Row4.presence = "hidden";

                    aTarget.Row5.presence = "hidden";

                    aTarget.Row6.presence = "hidden";

          }

}

Avatar

Level 9

radzmar,

I appreciate your help. The new script does work now to close the first occurence in the first topic but if i click to create a second topic, it does not hide any of the Action Items in that second topic section.

Avatar

Correct answer by
Level 10

Ah ok.

That's tricky but this script should do it.

for (var t = 0; t < _Table1.count; t += 1) {

          for (var a = 0; a < xfa.resolveNode("Table1[" + t + "]")._ActionItemGrp.count; a += 1) {

                    var aTarget = xfa.resolveNode("Table1[" + t + "].ActionItemGrp[" + a + "]");

                    if (!aTarget.Row5.ClosedDate.isNull) {

                              aTarget.Row3.presence = "hidden";

                              aTarget.Row4.presence = "hidden";

                              aTarget.Row5.presence = "hidden";

                              aTarget.Row6.presence = "hidden";

                    }

          }

}

Avatar

Level 9

Fantastic! Thank you so very much for all your help!

-Don