Copy link to clipboard
Copied
I hope someone can help me with this. I have a 3 page form that will spawn one template page when requested (via a check box). The template will possible need to be spawned anywhere from 0 to 120 times. For this reason, I need the fields on the spawned template page to be renamed. I know that the Acrobat naming convention adds a prefix (P#.Templatename.) to the spawned template's field names making existing field scripts ineffective. I understand the there is suppossed to be a way to use "event.target.page" to make the existing code work with the renamed fields. Unfortunately, I have no idea how to do this.
I tried adding this to the top of each fields calculation, validiation or action script:
var fieldName = event.target.name;
var groupName = fieldName.substring(0,fieldName.lastIndexOf(".")+1);
and then added: groupName + before the original field name in that script
but that didn't seem to work.
Here's an example on one check box action script with the above additions (in orange):
var fieldName = event.target.name;
var groupName = fieldName.substring(0, fieldName.lastIndexOf(".")+1);
this.getField(groupName + "DICT A").display = (event.target.value=="Yes")?display.visible:display.hidden;
this.getField(groupName + "DICAmt A").display = (event.target.value=="Yes")?display.visible:display.hidden;
if (event.target.value != "Off") {
this.getField(groupName + "DICAmt A").value = event.value;
this.getField(groupName + "DICsubA.AmtT A").value = event.value;
this.getField(groupName + "DICT A").value = event.value;
}
if (event.target.value == "Off") {
this.getField(groupName + "DICAmt A").value = "Off";
this.getField(groupName + "DICsubA.AmtT A").value = "Off";
this.getField(groupName + "DICT A").value = "Off";
}
getField(groupName + "DICE A").display = display.hidden;
getField(groupName + "DICI A").display = display.hidden;
getField(groupName + "DICsubA").display = display.hidden;
getField(groupName + "DICIsubA").display = display.hidden;
getField(groupName + "DICEsubA").display = display.hidden;
getField(groupName + "DICEsubAA").display = display.hidden;
getField(groupName + "DICEsubCA").display = display.hidden;
getField(groupName + "DICEsubWA").display = display.hidden;
getField(groupName + "BTNA").display = display.hidden;
Please note: The script (without the additions) was working before the template page was spawned, but obviously the additions are not working to accommodate the renamed fields. Also, this is just one of several fields that have a either an action, calculation or validation script on the template page.
Does anyone know how and where to alter the code(s) so that it will work with the renamed fields? Any help would be greatly appreciated!
Since I got no replies, I continued to research online and experiment with my file. The above might work, but I ended up using another addition to my template page scripts. I found it on another thread and the answer came from gkaiseril.
Here's what worked
Add the following to the the existing script for every field with a calculation/validation/action script on the template page:
var cPreFix = "";
var aFieldName = event.target.name.split(".");
if(aFieldName.length > 2)
{
cPreFix = aFieldName[0] + ".
...Copy link to clipboard
Copied
Since I got no replies, I continued to research online and experiment with my file. The above might work, but I ended up using another addition to my template page scripts. I found it on another thread and the answer came from gkaiseril.
Here's what worked
Add the following to the the existing script for every field with a calculation/validation/action script on the template page:
var cPreFix = "";
var aFieldName = event.target.name.split(".");
if(aFieldName.length > 2)
{
cPreFix = aFieldName[0] + "." + aFieldName[1] + ".";
}
In addition, you need to add:
cPreFix +
before each field name in the existing script.
For example, if existing script was:
if(event.value =="Other") {
this.getField("Text Field Name").display = display.visible;
} else {
this.getField("Text Field Name").display = display.hidden;
}
The new script to account for the renamed fields of a spawned template page would be:
var cPreFix = "";
var aFieldName = event.target.name.split(".");
if(aFieldName.length > 2)
{
cPreFix = aFieldName[0] + "." + aFieldName[1] + ".";
}
if(event.value =="Other") {
this.getField(cPreFix + "Text Field Name").display = display.visible;
} else {
this.getField(cPreFix + "Text Field Name").display = display.hidden;
}
I hope this is helpful to anyone else who has a template page with field scripts that need to work on a spawned page with renamed fields.
Copy link to clipboard
Copied
*Points at you in Robert Deniro voice: "You."
I been rackin my brain over this one for weeks. You are the man. Thanks for figuring this one out.