Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

How do I create a "Delete Page" button?

Avatar

Level 1

I am making a pdf that auto populates several other pages with data that is entered on the first page. I want to create a button that will delete a specified page if it is not needed. I want the button on page 1. Basically:

When this button on page one is clicked, I want it to delete (or hide) page 3.

(I'm a total newbie, so keep that in mind.)

7 Replies

Avatar

Former Community Member

Ok i'll try to make it simple for you.

first of all, open the script editor. To achieve this, go in the Palettes' menu and click on Script Editor (or press Ctrl + Shift + f5).

This screen will appear :

scripteditor.png

Now click on your button.

In the Show: drop down menu, select the click event :

clickevent.png

This is the place where you tell livecycle what happens when this button is clicked.

The code you want to write in it is the one to hide the page3. so what you first want to do, is to find the complete path to reach Page3.

To achieve this, look at your hierarchy tab, it should look like this :

hierarchy.png

In the script editor you write your code, first you write the path of your page. In my case, it would be :

data.Page2

Then, you have to say what you want it to do :

data.Page2.presence = "hidden"

This command means that your page will be hidden. To make sure this syntax will be correct, verify on the top right corner of your script editor if the language is FormCalc. If not, put it to FormCalc.

You can then do a Syntax Check syntaxcheck.png to make sure you didn't made any typing mistakes.

I'd say this is all you need to do to hide your page. If you have any other questions you just have to ask!

Max

Avatar

Level 1

I greatly appreciate the help! However, I still wasn't able to get it to work. Here is what I entered:

whelp!.jpg

I'm sorry I'm so terrible at this

Avatar

Level 2

Your language is set to Formcalc. I don't think Formcalc can set the presence property.

Avatar

Former Community Member

Formcalc can set the presence property, but just thinking of it, i think you cannot hide a "page", i think that if you want it not to appear, you have to hide everything in it instead.

We might need some more pro tips about this one.

Max

Avatar

Level 4

This was really helpful to me today because I also wanted to be able to delete a page and kept trying to remove an instance of the page I was trying to delete. So thank you for asking this question and getting me the answer altho I think it didn't help you too much.

I remeber when I was new and someone would answer my question and I had no idea what they were talking about. So I'm going to try and help.

You can put your button to delete the page on any page. I put mine on each page of an inventory template I was designing because each page had a different kind of table on it that was only used for certain items. If they weren't inventorying those items, then that page with the table wasn't needed on the inventory report. So what I did after reading this answer was to put a generic button on the page I wanted to delete. Again the button can go anywhere in the document.

Then I went up to the menu bar at the top of the LC window, and chose "Tools" from the list, then slid down to "Action Builder". In that window, I clicked the little scroll with the "A" on it to create a new action. So now I have a "condition" and a "result". I chose when (object) and clicked on the word object which opened a screen showing my form's hierarchy, where I clicked on the button that I wanted the action applied to (I always name my buttons what I want them to do like "remove pg3" so I don't get that one confused with other buttons in the list", then OK. Now I needed to tell LC what result I wanted. So using the drop down list I slid all the way to the bottom and chose "Show or Hide an Object". Then it said "Set the visibility of (object) to" and gave me another drop down. In your case, you want "(untitled Subform) (page 3)" to disappear, so click on that subform and OK, and then you want that subform (page) to be "hidden" in the drop down. Then OK. At this point, I suggest you save your form and then open it in Preview PDF or Adobe Reader. Click on the button and see if page 3 doesn't disappear from the form. If you have put page numbers in your form, it will subtract one page from the page numbers and that page is truly gone for that pdf.

The next time you open the origninal file again, it will be back along with the button to "hide" it again, but if you now save the form after hiding that page, it won't be there the next time you open that file.

The reason you want to choose to make the object "hidden" is because it will take it out of the page count and truly remove it from the form that you save. If you choose "invisible" there will be a blank page in your pdf and that probably isn't what you want.

You can also use this same process to make pages visible on button click. If I have a form where I am asking if someone is married, and their answer is no, then I don't need that section for their spouse's information to even appear on the form. In that case, I use a checkbox for yes to make that section visible, and a checkbox for no doesn't open that section.

Play around with the actions that you can apply to different objects and you'll discover that the "action builder" can become your best friend if you don't write javascript, like me.

I hope this helps you. It helped me. Thanks.