Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Object scripts stop working if I change other objects in another subform first?

Avatar

Level 2

The problem I'm having is a little difficult to explain, but I'll try:

I have a checkbox set up in a subforum which sets radio buttons from visible when checked, to hidden when unchecked using the following script in the change field:

-------------------

form1.P1.Sec3.intranet2.engineering::change - (FormCalc, client)

if(engineering == "1")then

      ebuttons.presence = "visible"

else

      ebuttons.presence = "hidden"

endif

---------------------

As long as I don't touch any other objects in another subform BEFORE changing these objects, the checkboxes work fine. If I change another object that runs a script in another subform first, say:

-------------------------------

form1.P1.Sec1.RequestType::change - (FormCalc, client)

var sel = $event.change

if (sel eq "Add") then

          form1.P1.Sec3.Rectangle1.presence = "hidden"

          form1.P1.Sec1.Modify1.presence = "hidden"

          form1.P1.Sec1.delete1.presence = "hidden"

          form1.P1.Sec1.delete2.presence = "hidden"

          form1.P1.Sec1.delete3.presence = "hidden"

          form1.P1.Sec1.name1.presence = "hidden"

          form1.P1.Sec1.name2.presence = "hidden"

          form1.P1.Sec1.fname.presence = "visible"

          form1.P1.Sec1.startdate.presence = "visible"

          form1.P1.Sec1.dept.presence = "visible"

          form1.P1.Sec1.location.presence = "visible"

          form1.P1.Sec1.position.presence = "visible"

          form1.P1.Sec1.empstatus.presence = "visible"

          form1.P1.Sec1.reports.presence = "visible"

elseif (sel eq "Modify") then

          form1.P1.Sec1.delete1.presence = "hidden"

          form1.P1.Sec1.Modify1.presence = "visible"

          form1.P1.Sec1.delete2.presence = "hidden"

          form1.P1.Sec1.delete3.presence = "hidden"

          form1.P1.Sec1.fname.presence = "hidden"

          form1.P1.Sec1.startdate.presence = "hidden"

          form1.P1.Sec1.dept.presence = "hidden"

          form1.P1.Sec1.location.presence = "hidden"

          form1.P1.Sec1.position.presence = "hidden"

          form1.P1.Sec1.empstatus.presence = "hidden"

          form1.P1.Sec1.reports.presence = "hidden"

elseif (sel eq "Delete") then

          form1.P1.Sec3.Rectangle1.presence = "hidden"

          delete1.presence = "visible"

          delete2.presence = "visible"

          delete3.presence = "visible"

          Modify1.presence = "hidden"

          fname.presence = "visible"

          startdate.presence = "hidden"

          dept.presence = "visible"

          location.presence = "visible"

          position.presence = "visible"

          empstatus.presence = "visible"

          reports.presence = "visible"

          name1.presence = "hidden"

          name2.presence = "hidden"

          position1.presence = "hidden"

          position2.presence = "hidden"

          dept1.presence = "hidden"

          dept2.presence = "hidden"

endif

-----------------------------

And then try going to the first mentioned subform and try to change anything, the script doesn't run and the radio buttons never change their visibility state.

HOWEVER, if I first change the state of an object in the first subform, go to another and make a change there and then go back to the first subform and make another change, it will work BUT the other subforms which were not changed will fail to work at all.

I'd like all subforms to function no matter which subform/object is changed first. I assume this is possible but I'm not sure how/why I'm having this issue.

1 Accepted Solution

Avatar

Correct answer by
Level 10
10 Replies

Avatar

Level 2

Anyone have any thoughts on this? I'm wondering if it has something to do with the subforms-within-subforms.

Avatar

Level 10

Hi,

change the script for the 'intrenet2' subform into:

if ($.rawValue eq 1) then

      $.resolveNode("ebuttons").presence = "visible"

else

      $.resolveNode("ebuttons").presence = "hidden"

      $.resolveNode("ebuttons").rawValue = ""

endif

Avatar

Level 2

I assume you wanted me to put that under "Change" in place of:

if(engineering == "1")then

form1.P1.Sec3.intranet2.ebuttons.presence = "visible"

else

form1.P1.Sec3.intranet2.ebuttons.presence = "hidden"

endif

If so I replaced what I had with what you gave me, and the form still behaves the same way.

Avatar

Level 10

Ah yes, I see.

The thing with showing/hinding Rectangle1 caused this strange effect in your form is very bad style.

Remove that rectangle, you don't need it.

There are two more things you have to change.

1. The change script of 'RequestType":

var sel = $event.change

if (sel eq "Add") then

          Sec3.presence = "visible"

          Modify1.presence = "hidden"

          delete1.presence = "hidden"

          delete2.presence = "hidden"

          delete3.presence = "hidden"

          name1.presence = "hidden"

           name2.presence = "hidden"

          fname.presence = "visible"

          startdate.presence = "visible"

          dept.presence = "visible"

          location.presence = "visible"

          position.presence = "visible"

          empstatus.presence = "visible"

          reports.presence = "visible"

elseif (sel eq "Modify") then

          Sec3.presence = "hidden"

         delete1.presence = "hidden"

         Modify1.presence = "visible"

          delete2.presence = "hidden"

          delete3.presence = "hidden"

          fname.presence = "hidden"

          startdate.presence = "hidden"

          dept.presence = "hidden"

          location.presence = "hidden"

          position.presence = "hidden"

          empstatus.presence = "hidden"

          reports.presence = "hidden"

elseif (sel eq "Delete") then

          Sec3.presence = "visible"

          delete1.presence = "visible"

          delete2.presence = "visible"

          delete3.presence = "visible"

          Modify1.presence = "hidden"

          fname.presence = "visible"

          startdate.presence = "hidden"

          dept.presence = "visible"

          location.presence = "visible"

          position.presence = "visible"

          empstatus.presence = "visible"

          reports.presence = "visible"

          name1.presence = "hidden"

          name2.presence = "hidden"

          position1.presence = "hidden"

          position2.presence = "hidden"

          dept1.presence = "hidden"

          dept2.presence = "hidden"

endif

2. Remove the unneccessary script in the enter event of 'RequestType"

Avatar

Level 2

I couldn't figuree out how to get the section to show/hide so I used the rectangle, but it looks like you did so the rectangle is gone.

I removed the garbage in Enter and replaced the rectangle refrences with the sec3 hidden/visible script where needed, and now it looks like everything is working. Thanks radzmar!

I am left wondering why the rectangle made the form behave that way. Did it have to do with how it was layered?

Avatar

Level 2

Actualy I take that back... The checkboxes stop working in other subforms once a script is already run elsewhere. Here is the new file with the changes made:

http://www.mediafire.com/view/?46ia74v75ifq3v0

Avatar

Correct answer by
Level 10

I made a couple of changes.

Should work now.

https://acrobat.com/?d=sCEZTo*Xwdrd6uXQUagsxg

Avatar

Level 2

Yup works now!

What changes did you make?

Avatar

Level 10

I changed all checkbox scripts in the same format and also added the command $layout.relayout(), to force a relayout of the form when ever changes have been made of any checkbox because the target version of your form required this.