Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Changing the presence property of multiple items failure

Avatar

Level 2

Hello,

I'm trying to execute the following code, as a single item in a button click event, but it fails, with only STEP2 section and SAVE AS being executed properly:

form.frmMaster.Master1.FileStampButtons.RejectButton::click - (JavaScript, client)

/* --STEP 1 -- Disable/Hide all buttons except PRINT */

this.presence = "invisible";

AcceptButton.presence = "invisible";

/* --STEP 2 --  Change File Stamp to reflect REJECTED ; IOW, remove file stamp */

pg1.sfCap.sfCapLower.Text25.presence = "invisible";

pg1.sfCap.sfCapLower.Text26.presence = "invisible";

pg1.sfCap.sfCapLower.TextDeputy.presence = "invisible";

pg1.sfCap.sfCapLower.Text28.presence = "invisible";

pg1.sfCap.sfCapLower.CurrentDate.presence = "invisible";

pg1.sfCap.sfCapLower.Line1.presence = "invisible";

/* Quick-Auto-save form to share drive -- Note must do SAVEAS due to Adobe Reader Security Constraints */

app.execMenuItem("SaveAs");

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

The odd thing is that if I disable the code for STEP 2, then the code for STEP 1 works just fine, so they appear to not be able to coexist.  Is there a limit as to how many items can be manipulated at a time or within a section of the form?  (The RejectButton is in a Master page, while the items in STEP2 are in the main page).  Thanks for your help.

-Veni

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I had a look onto the form you send me.

There are several reasons why my suggested method doesn't work.

1. The console shows umpteen errors for missing references on several pages. This really needs to be corrected before you add further functions to the form.

2. You have 2 masterpages in your form, so the code for (var i = 0; i < xfa.host.numPages; i++)... cannot be used.

3. The masterpage with the buttons occurs only once, so I suggest to put the buttons directly onto that body page, where you need them and then remove the 1st master page completely. You then can use the same method to hide the buttons as you used for the textfields.

4. The pagination settings you choosed for the body pages is odd. For all body pages excepting the first you choosed "Go To Next Page". This is only needed where you want to switch from one to another master page. All ...

View solution in original post

4 Replies

Avatar

Level 10

Hi,

when you try to modify form objects on masterpages and body pages with one action you will need to write a function.

Create a script object "MyActions" with two function.

One for the masterpages, one for the body pages.

// Function to affect the objects on all instances of the master page

function ModMP()

     {

     for (var i = 0; i < xfa.host.numPages; i++)

          {

          var oSubform = xfa.resolveNode("form.frmMaster.Master1[" + i + "].FileStampButtons");

          oSubform.RejectButton.presence = "hidden";

          oSubform.AcceptButton.presence = "visible";

          }

     }

// Function to affect form objects on the body page

function ModBP()

     {

     pg1.sfCap.sfCapLower.Text25.presence = "invisible";

     pg1.sfCap.sfCapLower.Text26.presence = "invisible";

     pg1.sfCap.sfCapLower.TextDeputy.presence = "invisible";

     pg1.sfCap.sfCapLower.Text28.presence = "invisible";

     pg1.sfCap.sfCapLower.CurrentDate.presence = "invisible";

     pg1.sfCap.sfCapLower.Line1.presence = "invisible";

     }

From your click:event you then execute the two functions successively.

     MyActions.ModMP();

     MyActions.ModBP();

     app.execMenuItem("SaveAs");

Avatar

Level 2

Thanks for the suggestion!  I tried it, but I still have the same issue:  if I change the order of execution for each of the function calls, then the first one to execute works just fine, but the second fails consistently.  Does it matter that 'FileStampButtons' refers to a subform in the master page?  Thanks, again.

-Veni

Avatar

Correct answer by
Level 10

Hi,

I had a look onto the form you send me.

There are several reasons why my suggested method doesn't work.

1. The console shows umpteen errors for missing references on several pages. This really needs to be corrected before you add further functions to the form.

2. You have 2 masterpages in your form, so the code for (var i = 0; i < xfa.host.numPages; i++)... cannot be used.

3. The masterpage with the buttons occurs only once, so I suggest to put the buttons directly onto that body page, where you need them and then remove the 1st master page completely. You then can use the same method to hide the buttons as you used for the textfields.

4. The pagination settings you choosed for the body pages is odd. For all body pages excepting the first you choosed "Go To Next Page". This is only needed where you want to switch from one to another master page. All ...

Avatar

Level 2

Thanks for your help!!!  My form is working now, after making the changes you suggested.  My apologies for not including all the fragment code within the form -- thus the errors you were seeing.  Thanks, again.

-Veni