Expand my Community achievements bar.

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

Script to add a new page in LiveCycle

Avatar

Level 1

I am new to LiveCycle so please forgive my ignorance. I have 2 things I am trying to do.

1. In my fillable form, I want to have default text in the the form field that appears in light gray and disappears automatically when a user clicks in the field to enter text. I know how to add a default but then my user would have to erase the default to add their own information. I don't know if this is an easy thing or if it needs scripting.

2. I created a button and I want to add JavaScript to it to have it copy the second page of my form and add it as a third page to be filled out too. I don't want to send a form with a bunch of extra pages so I want my users to create new pages as necessary. I know how to view the script editor and I added some script, but it doesn't appear to be correct as I don't get the green or red icons to attach the script to the button and when previewed, the button does nothing. I chose on Click and I understand that the script creates a path to my object with a period in between each object, but I don't understand after the instanceManager.addInstance(true) what I should put. What does the "true" part mean. I thought that I would put the name of the object that I wanted added. Am I close to doing this right or is it much more complicated? Does my button have to be in a subform with the objects or something to work? Am I trying to do something that is possible?

I wish I could printscreen to this forum.

2 Replies

Avatar

Level 6

For each of the fields that you like to have default value displayed and get cleaned on entry you can have following JS script in "enter" event....

if (this.rawValue == "<default value for that particular field>") {

     this.rawValue = ""

}

and for "exit" event....

if (this.isNull) {

     this.rawValue = "<default value for that particular field>"

}

Hope tha helps with the first issue....

And with the second question you had....yes it is some thing that can be done with few tricks and little script.

Your button does not need to be part of that subform...and noting wrong even if it is.

instanceManager.addInstance(true)     //true is part of syntax however following example can give you better idea

_secondPageSubForm.addInstance(true) is what you would use in "click" event of the button where "secondPageSubForm" is your subform name to repeat and designed to fit entire page so you can continue adding entire page rather than part of page. And "_" (Underscore) is part of the syntax to recognize the repeating subform.

And to whole thing work as expected you need to save/render PDF as Dynamic template and set your "secondPageSubForm" as repeating in "Binding" tab.

Hope that helps, Good Luck,