Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Visible subform on screen

Avatar

Level 3

Hi,

I am wanting to have a subform that can be filled in on screen but does not print and does not take up space on the page when printed. This subform will also contain global binding with fields in other subforms. Can this be done?

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Yes, it can be done, but will require script.

The issue is that while in the Object > Field palette you can set the subform's presence to "Visible (screen only)", this will still take up a blank space on the printout.

Solution is to have the following script in the subform's prePrint event:

this.presence = "hidden"; // to hide the subform

And this script in the postPrint event:

this.presence = "visible"; // to show the subform again

Hope that helps,

Niall

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Hi,

Yes, it can be done, but will require script.

The issue is that while in the Object > Field palette you can set the subform's presence to "Visible (screen only)", this will still take up a blank space on the printout.

Solution is to have the following script in the subform's prePrint event:

this.presence = "hidden"; // to hide the subform

And this script in the postPrint event:

this.presence = "visible"; // to show the subform again

Hope that helps,

Niall

Avatar

Former Community Member

Morning

This is exactly the problem that I'm having but I'm not proficient in scripting so am unsure where the Pre and Post printing events are.  I've pasted the relevant scripting below and I'd greatly appreciate if you could point out what I need to be changing to have the field visible on screen but hidden from priniting and speciifcally not to take up space on the print out.

Many thanks

<field name="DropDownList1" w="88.9mm" h="8.875mm" relevant="-print">

            <ui>

               <choiceList>

                  <border>

                     <?templateDesigner StyleID aped3?>

                     <edge stroke="lowered"/>

                  </border>

                  <margin/>

               </choiceList>

            </ui>

            <font typeface="Arial" size="12pt"/>

            <margin topInset="1mm" bottomInset="1mm" leftInset="1mm" rightInset="1mm"/>

            <caption reserve="0.01in">

               <value>

                  <text>Permitted Period</text>

               </value>

            </caption>

            <items save="1">

               <text>Claimant has a Permitted Period</text>

               <text>Claimant does not have a Permitted Period</text>

            </items>

            <event activity="change" name="event__change">

               <script contentType="application/x-javascript">//+ GENERATED - DO NOT EDIT (ID:A6DF466E-2C8E-4F75-97D3-B63A318FFA01 CRC:2272057369)

//+ Type: Action

//+ Result4: SetPresence("$Node5","hidden")

//+ Result3: SetPresence("$Node4","hidden")

//+ Result2: SetPresence("$Node3","hidden")

//+ Result1: SetPresence("$Node2","visible")

//+ Node5: form1[0].TextFieldContainer[0].#subform[2].Text20[0]

//+ Node4: form1[0].TextFieldContainer[0].Text15[0]

//+ Node3: form1[0].TextFieldContainer[0].#subform[2]

//+ Node2: form1[0].TextFieldContainer[0].Text16[0]

//+ Node1: form1[0].TextFieldContainer[0].DropDownList1[0]

//+ Condition1: ListField("$Node1","textselected","Claimant does not have a Permitted Period")

//+ ActionName: DropDownList1.change

if ($.boundItem(xfa.event.newText) == "Claimant does not have a Permitted Period") {

  this.resolveNode("Text16").presence = "visible";

  this.resolveNode("#subform[2]").presence = "hidden";

  this.resolveNode("Text15").presence = "hidden";

  this.resolveNode("#subform[2].Text20").presence = "hidden";

}

//-

//+ GENERATED - DO NOT EDIT (ID:1E31FE8F-BBE2-4450-A3CD-D585C0D71D15 CRC:2982098794)

//+ Type: Action

//+ Result4: SetPresence("$Node5","visible")

//+ Result3: SetPresence("$Node4","hidden")

//+ Result2: SetPresence("$Node3","visible")

//+ Result1: SetPresence("$Node2","visible")

//+ Node5: form1[0].TextFieldContainer[0].#subform[2].Text20[0]

//+ Node4: form1[0].TextFieldContainer[0].Text16[0]

//+ Node3: form1[0].TextFieldContainer[0].Text15[0]

//+ Node2: form1[0].TextFieldContainer[0].#subform[2]

//+ Node1: form1[0].TextFieldContainer[0].DropDownList1[0]

//+ Condition1: ListField("$Node1","textselected","Claimant has a Permitted Period")

//+ ActionName: DropDownList1.change

if ($.boundItem(xfa.event.newText) == "Claimant has a Permitted Period") {

  this.resolveNode("#subform[2]").presence = "visible";

  this.resolveNode("Text15").presence = "visible";

  this.resolveNode("Text16").presence = "hidden";

  this.resolveNode("#subform[2].Text20").presence = "visible";

}

//-

</script>