These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Integration of

kpdamm
Registered: Oct 9 2009
Posts: 11

Hello,

Background: I have a process created within LiveCycle Workbench that assigns a form to a user through the AssignUser service. The form (task) appears in the user's 'To-Do' queue. The process in workbench has three routes, appear as options to the user at the bottom of the form.

Request: I am looking for a solution that will manipulate object properties within my form based on the route a user chooses in WorkSpace. Specifically, my form has a few fields in it that are 'User Entered - Required'; this means that these fields must be filled out prior to the user choosing one of the routes in WorkSpace. I would like a means to change the properties of these fields to 'User Entered - Optional', if a specific route is selected. I would assume this could be done through scripting. One caveat, I need this solution to work without calling out specific fields on the form. I am hoping there is a global property that can be set through scripting to change all fields to 'User Entered - Optional'.

Specific Use Case:
Here's the specific use case that I need this form. A user is presented with three options for each form in their To-Do queue. One of these options is 'Delete from Queue'. We would like the user to select this option without having to fill out the required fields in the form. Our client has ~400 destinct forms, so it would be a nightmare if each form had a specific scirpting solution that said change the properties of this particular field to 'User Entered - Optional'. Rather I am looking for a solution that would change the properties of all fields that have 'User Entered - Required' to 'User Entered - Optional' regardless of the field's name.

I realize this request is rather complex and difficult to understand. If you have any questions around this request please feel free to post back. I appreciate any help on this task. Thanks.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
First off. This question is probably better asked on the LiveCycle forum.

But, "User Entered - Required" is really two properties, "field.access" and "field.mandatory". It's no problem to use a script to walk through all the fields on the form filtering based on these properties. To modify the field to "User Entered - Optional", change the "field.mandatory" property to "disabled".

For writing these scripts you'll need the "AdobeĀ® XML Form Object Model Reference". You can download this from:

http://partners.adobe.com/public/developer/xml/topic.php

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

kpdamm
Registered: Oct 9 2009
Posts: 11
Thanks Thom. Do you have an example of looping through all fields within a form? From how I understand your answer, I should write a script that will loop through all of the fields within a form, check if the field.mandatory property is set to enabled, and if it is, set it to disabled.
Your other response got me thinking about the order in which this script runs with respect to the inherent check within Designer that all required fields are filled out. Will my script run before this check; otherwise I don't think it will have much effect.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
One way to do this is to use the "pageContent()" function in the layout model. You can use it to return a list of fields on each page of the form. Look it up in the XML Object Model reference.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

kpdamm
Registered: Oct 9 2009
Posts: 11
I have been able to set the mandatory property to "disabled" for fields in question. However, I am not able to reverse this logic to check if any fields exist with the mandatory property set to not disabled. Below is the code in question that should achieve this. Unfortunately, even if all mandatory (user required) fields have been filled in, my code (see below) still 'thinks' that field objects exist with the mandatory property set to not disabled.
Any help is greatly appreciated!

if( "Print" == AWS_ACTION.rawValue )
{
//Create a flag to capture if printing should be enabled; this means the mandatory property of all field objects is set to disabled
var PrintFlag = true;

//Loop through all the pages on the form
for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++)
{
//Create an array of all the field objects on the nPageCount page of a form
var oFields = xfa.layout.pageContent(nPageCount, "field");
var nNodesLength = oFields.length;

//Loop through all the field objects on nPageCount page
for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++)
{
//If the mandatory property of any field on the page is not set to disabled, printing cannot occur
if(oFields.item(nNodeCount).mandatory != "disabled" )
{
PrintFlag = false;
xfa.host.messageBox("print flag is false" )
break
}
}
if (PrintFlag == false)
{
break
}
}
//If no field objects were found with the mandatory property not set to disabled, then go ahead and print
if (PrintFlag == true)
{
xfa.host.print(1, "0", "0", 0, 1, 0, 0, 0);
}
}
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Do you mean that you ran code that changed all the fields to "disabled", and then when you ran the checking code it still says that there are fields that are not set to disabled?

Or do you mean that you think that entering data automatically sets "mandatory" to disabled? Because, filling in a form field does not change the "mandatory" property.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

kpdamm
Registered: Oct 9 2009
Posts: 11
Ah, therein lies the crux of my logic.

Your first comment ("...ran code that changed all the fields to...") actually applies to a different form. Your second comment is spot on. I thought that filling in a required field changes that field's mandatory property to disabled. You seem to suggest this is not correct.
Konstantin
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I'll go beyond suggesting and say with conviction that filling in a required field does not change the mandatory property. The mandatory property actually sets what's called the Null Test for the field. You can see it in the XML for the field. Unless specifically modified in code, the null test is always the same. It's how Acrobat tests a field to determine whether or not it should whinge about it.

If you want a script to know whether not a required field is filled in then the script has to test it.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

kpdamm
Registered: Oct 9 2009
Posts: 11
So if I understand you correctly, the mandatory property is solely used to specify the nullTest value for a field. However, to check what a field's nullTest value is, a user must check the nullTest property?
e.g. field.nullTest = "disabled"

Or does the nullTest property not change unless it is specified through the mandatory property? If that's the case, then how would you suggest to identify if a user has filled in a required field?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
To see if a field is filled in the code has to test the fields value. I prefer to use this regular expression

var rgEmpty = /^\s*$/;
if(rgEmpty.test(MyField.rawValue))
//Then field is empty

You can test my theory about the null test from the console window by writing code snippets to modify the mandatory property and then check the null test value.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script