Expand my Community achievements bar.

SOLVED

Preventing printing page based on field value

Avatar

Level 2

Hi. Is it possible to prevent certain pages from printing based on the value of a field in the form?

Similarly, is it possible to prevent certain pages from being displayed based on a field value?

I am by no means an accomplished JS coder.

Windows XP

LiveCycle Designer ES2

Thanks in advance

Gary, NJ

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Hi,

  I doubt whether your if condition is working or not. Can you try with the couple of things:

1) Write the same code in Textfield exit event instead of the current enter event.

2) Check if the if condition is working for "xyz" value or not by using simple alert in the condition.

if (topmostSubform.Page1.TextField1.rawValue == "xyz") {
Page2.presence = "hidden";

app.alert("page hidden condition"); //just for test purpose..remove it at later point of time
}
else {
Page2.presence = "visible";

app.alert("page visible condition");
}

This will help you to know whether this condition is actually working or not.

"Hidden" will make a page hidden as well as it will not print it.

Hope this should work for you.

kc

View solution in original post

5 Replies

Avatar

Former Community Member

Yes, it is possible.

To prevent a page from printing, you can make that page as hidden.

You can use the following script in the event you want to trigger.

In javaScript,

if (textfield1.rawValue == "xyz") {

Page2.presence = "hidden";

}

else {

Page3.presence = "visible";

}

Hope this helps.

----------

kc

Avatar

Level 2

Thanks KC. However no luck. Using XP, ES2.

Premise: I have a form that has 2 pages. If the content of Page1.TextField1 = "xyz", then only print Page1, otherwise print Page1 and Page2.

Here's my code --

topmostSubform.Page1.TextField1::enter - (JavaScript, client)

if (topmostSubform.Page1.TextField1.rawValue == "xyz") {
Page2.presence = "hidden";
}
else {
Page2.presence = "visible";
}

Page2 always prints. Do you think I need to configure a setting in options somewhere for this to work?

Also, and perhaps more important, is there a way to prevent Page2 from being displayed on the screen if TextField1 = "xyz". (Unless I misunderstand. Does "hidden" mean to not print and not display).

Thanks for your help.

G

Avatar

Correct answer by
Former Community Member

Hi,

  I doubt whether your if condition is working or not. Can you try with the couple of things:

1) Write the same code in Textfield exit event instead of the current enter event.

2) Check if the if condition is working for "xyz" value or not by using simple alert in the condition.

if (topmostSubform.Page1.TextField1.rawValue == "xyz") {
Page2.presence = "hidden";

app.alert("page hidden condition"); //just for test purpose..remove it at later point of time
}
else {
Page2.presence = "visible";

app.alert("page visible condition");
}

This will help you to know whether this condition is actually working or not.

"Hidden" will make a page hidden as well as it will not print it.

Hope this should work for you.

kc

Avatar

Level 10

Hi,

I think that there may be a more fundemental problem.

When the root node is "topmostSubform", it indicates that the form was created by importing an existing Word or PDF document.

It really depends on how you imported the existing document. In some cases, you cannot save the form as a Dynamic XML Form, which would be needed for this type of dynamic behaviour (showing/hiding pages).

So to start, I would recommend checking if you can save the form as a Dynamic XML Form in the save as dialog:

LC SaveAs Dialog.png

If you can't save your form as a Dynamic XML Form, then you will not be able to achieve what you are looking for.

Good luck,

Niall

Avatar

Level 2

Thank you both KC and Niall. Taking the instruction from both of you enabled me to print select pages.

As Niall had noted, I had imported another pdf into LiveCycle. Given that, when importing it REALLY helps to select the "Create an Interactive Form with a Flowable Layout" option rather than creating one with fixed pages.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----