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.

Optional Page

Avatar

Former Community Member

Hi,

Status:

Unresolved

Problem:

We have a page which only may occur if a certain attribute is set to a certain value. LC cannot set the presence of a Page to "hidden".

Situation:

We have 4 production states, DEV, TEST, ACCEPT and PRODUCTION. If the production state is DEV, TEST or ACCEPT the final page may not be generated. The final page is a legal disclaimer containing fixed texts in subforms

Solution:

You tell me, because I do not find any way of making a page optional, not using the designer's gui nor through scripting in JavaScript nor FormCalc.

Thanks in advance!

10 Replies

Avatar

Level 10

Hi,

Is the production state a series of radio buttons or a drop-down list?

In either case make sure to "specify values" in the Object / Binding tab.DEV = 1;  TEST = 2; ACCEPT = 3; and PRODUCTION = 4.

Then on the exit event have somethin along the lines of:

if (this.rawValue <= 3)

{

     form1.conditionsPage.presence = "hidden";

}

if (this.rawValue == 4)

{

     form1.conditionsPage.presence = "visible";

}

If using radio buttons you would need the script in the exit event of all radio objects in the group. That way a dropdown list is better. The second if statement could be replaced with an else statement if you like, I am just being specific.

Hope that helps,

N.

Avatar

Former Community Member

Thanks for your contribution so far, unfortunately this does not do the trick for me.

First of all, I should have mentioned this in my initial post, the Environment is being loaded through XML binding. The value is accessed like this:

if ($.record.CommonMetaData.Environment <> "PRODUCTION") then

     Orderform.PageSet.LastPage.presence = "hidden"

endif (FormCalc)

It appears that MasterPages do not have the attribute .presence which makes it impossible to hide a masterPage?

Thanks for the input so far but it did not solve my problem

Avatar

Level 10

OK, Why not set the conditions page up as a page within the layout. It can still be based on your master (conditions) page.

You would then be able to control its presence.

Setup an additional page at the end of the layout. Then in its Object / Pagination tab set the place where you want this additional page to be laid out. Instead of "Following Previous" set it to go to the specific Master Page (example below for one master page; in your case you would have more than one and you could select this).

Its worth a try - I still think that you can get your form to do what you want.

Good luck,

Niall

Avatar

Former Community Member

Hey,

We're closing in on a success here!

I was able to manage and hide this page as you mentioned however it appears that my script partly does not work.

> Orderform

>> PageSet

>>> LastPage

>>>> subform

>>>>> script:

if ($record.CommonMetadata.Environment == "PROD") then

     $.presence = "hidden"; // WORKS

     Orderform.Document.Footer.presence = "hidden"; // DOES NOT WORK

endif

I also tried scripting the initialze of the footer itself:

if ($record.CommonMetadata.Environment == "PROD") then

     $.presence = "hidden"; // DOES NOT WORK

endif;

However, if i set Orderform.Document.Footer (=subform) to visibility "hidden" the last page is not generated as expected. This is great, however then I do not have the ability to make it visible again

I feel that we are very close to a working solution, the only problem is to make the footer "visible" through scripting.

Here is the structure of the Hierarchy, I tried scripting in the regions indicated with '*' and i copy pasted the if-structure from above, aka formcalc.:

Orderform

     PageSet

          FirstPage

               Elements 0..n *

          NextPages

               Elements 0..n

          LastPage

               Elements 0..n *

     Document *

               Header

                    Elements 0..n

               Details

                    Elements 0..n

               Footer *

                    Elements 0..n *

     (variables none)

    

I might also have to mention that I CAN access XML data using formCalc but i CANNOT do this using JavaScript ?!

Almost there, thanks already!

Avatar

Level 10

Good,

I think what is happening is that some of your script is in a master page object and and while is referring to itself, it is also referring to an object on the main pages.

If the data you are testing and the objects are on the main pages, I would put the script on the main page as well.

I would normally use JavaScript for this and would resolve the name, where it is referring to an object on the master page (Page 1 = master page; p1 = layout page):

var oReference = xfa.resolveNode("xfa.form.form1.#pageSet[0].Page1.logoImage");


if (form1.p1.group.rawValue == 1) {
    oReference.rawValue = mainLogo.value.image.value;

}

Where you are using Formcalc I think that stick with the script in the LastPage.subform as you have it, just delete the semicolon and delete the line that is not working:

if ($record.CommonMetadata.Environment == "PROD") then

     $.presence = "hidden" // delete the semicolon

endif

Next make some small changes to the Formcalc in the footer (which I presume is in the main pages)...

if ($record.CommonMetadata.Environment == "PROD") then

     $.presence = "hidden" // delete the semicolon

endif // delete the semicolon

The additional semicolons may have been affecting the script. When testing press Control+J and see if any errors are showing up in the console.

Sorry I cannot be of more direct help,

N.

Avatar

Former Community Member

Starting to give up hope. I tried what you said and it also partly works.

I put the Orderform.Document.Footer on default precense hidden.

Initialize event of a subForm on the MasterPages itself executes the following code:

if ($record.CommonMetaData.Environment == "PROD") then

     Orderform.Document.Footer.presence = "visible"

endif

This works, yet it makes all my other scripts fail, it claims that $record.CommonMetaData.Environment is invalid, yet it does not complain one bit if I write $.presence = "hidden" instead of referring to the object in the "layout".

I find it hard to believe that I can't hide a page and even more strange that a masterPage does not have the attribute "presence", this would have made my battle vs Designer much, much easier.

Avatar

Former Community Member

Ok I found an alternative way of not displaying the page, but it comes with a very strange side-affect.

I made a copy of my original to play with, and I wrote this piece of code only:

Orderform.Document::initialize - (FormCalc, both)

if

($record.CommonMetaData.Environment <> "PROD") then

$.Footer.instanceManager.removeInstance(0)

endif

This works in the copy-version, yet if I write this in the orignal I get the error "Error: accessor '$.Footer.instanceManager.removeInstance("0")"

I do NOT understand this _at all_ because after receiving the error I set every field equal in the original file compared to the copy-version. The code is being ran in the sam language, both client & server, Footer & Document have the exact same Object/Pagination/ ... settings.

Yet it only works in the copy-version, without any problem whatsoever, but in the original version it just refuses to work. I'm really stunned by this effect as I'm starting to wonder if the PDF is being generated @random or something because I cannot explain this behaviour in any other way.

Is there anyone who has any idea what the problem might be? I really am disappointed because I have a solution which works perfectly, yet it appears that LiveCycle is starting to hate me...

Avatar

Former Community Member

I had to put the script in the Footer subform instead of the Document (= parent of Footer)

Why the 2 files behave in another way is beyond my knowledge but I got it working and I'm happy with the final result.

Never change a working program... this wont get edited for a loooooooooong looooong time.

Thanks for all the support I received here, although I found the solution myself you guys were the ones that put me on the right track! Thanks

Avatar

Level 10

I am out at the moment, if you want you could email it to niall.odonovan@assurehsc.ie and I can try and look at it later.

Niall

Avatar

Former Community Member

As you could have read I solved this issue myself, but thanks for the offer anyway, I had loads of help from your comments through-out this discussion. Please close this thread.