Copy link to clipboard
Copied
Can anyone help, I have provided a link to a PDF I have spent more than a day trying to fix, I have visited many forums and goole searches, basically I have a button on Page 2 to copy field values from Page 1, it does not do anything with the latest version of Adobe Acrobat Reader DC but it does work with FoxItPhantom.
Any help would be greatly appreciated.
Problem PDF Link
Replace the line
if (this.getField ("Site_Name"))
with
if (!this.getField ("Site_Name.Site_Name"))
This looks to be working now, thanks so much Bernd and Nesa.
I don't suppose many people will get into the same problem as me but I am posting the final script for reference.
if (!this.getField ("Site_Name.Site_Name"))
{
var tSite1 = this.getField("Site_Name").valueAsString;
var tSite2 = this.getField("C_Site_Name");
var tAddress1_1 = this.getField("Address_1").valueAsString;
var tAddress1_2 = this.getField("C_Address");
var tAddress2_1 = this.getField("Address_2").valueAsString;
var tAddress2_
...
Copy link to clipboard
Copied
Use this:
tSite2 = tSite1;
tAddress1_2 = tAddress1_1;
and so on
Copy link to clipboard
Copied
Thank you I really appreciate this but I am still struggling.
New Link Here
Copy link to clipboard
Copied
oK, was a mistake.
Use this:
var tSite1 = this.getField("Site_Name");
var tSite2 = this.getField("C_Site_Name");
var tAddress1_1 = this.getField("Address_1");
var tAddress1_2 = this.getField("C_Address");
and so on
tSite2.value = tSite1.value;
tAddress1_2.value = tAddress1_1.value;
and so on
Copy link to clipboard
Copied
I am sorry but still not working, do I have my { } in the wrong place or something else, I really appreciate your time, if you do this for a living I would like to exchange business emails for potential future paid work.
Latest Version here
Copy link to clipboard
Copied
There's something wrong with the field names on page 1. The first one, for example, is called "Site_Name.Site_Name", instead of just "Site_Name". Rename them and it should work fine.
Copy link to clipboard
Copied
Fix duplicate names and use this code:
var tAddress1_1 = this.getField("Address_1").valueAsString;
var tAddress1_2 = this.getField("C_Address");
var tAddress2_1 = this.getField("Address_2").valueAsString;
var tAddress2_2 = this.getField("C_Address_2");
var tTown1 = this.getField("Town").valueAsString;
var tTown2 = this.getField("C_Town");
var tCounty1 = this.getField("County").valueAsString;
var tCounty2 = this.getField("C_County");
var tPostcode1 = this.getField("Postcode").valueAsString;
var tPostcode2 = this.getField("C_Postcode");
var tTelephone1 = this.getField("Tel_Number").valueAsString;
var tTelephone2 = this.getField("C_Telephone");
var tMobile1 = this.getField("Mobile_Number").valueAsString;
var tMobile2 = this.getField("C_Mobile");
tSite2.value = tSite1;
tAddress1_2.value = tAddress1_1;
tAddress2_2.value = tAddress2_1;
tTown2.value = tTown1;
tCounty2.value = tCounty1;
tPostcode2.value = tPostcode1;
tTelephone2.value = tTelephone1;
tMobile2.value = tMobile1;
Or check this updated file : copy fields problem update
Copy link to clipboard
Copied
Oh I see !, thank you for spotting this.
We had some software written for us that "Pushes" data to the form, it looks like it corrupts some of the fields.
There is no way for me to change the names after it has been pushed as it will with the client after that, the form is used in two ways, one when they push data to it and one when they don't - so I guess I will have different field names but the code needs to work for both scenarios, would it do any halm to have one script that attempts to populate both versions of the field structure ?
Copy link to clipboard
Copied
You can test the field:
If (this.getField (" field name ")) {
...
}
Copy link to clipboard
Copied
In that case you can just adjust your code to access the full field name, like this:
var tSite1 = this.getField("Site_Name.Site_Name");
Copy link to clipboard
Copied
Hi everyone, thank you so much for all the replies and Nesa for providing a working example.
Now I need to try and check for both situations of the form and Bernd got me started on that (thanks).
I can confirm that the new version works fine when no data has been pushed to it but the scenario after data pushed is not working, the new linked version is the non working one, does anyone have a suggestion now (It feel close to a solution now).
The responses have been really appreciated.
Latest Version here
Copy link to clipboard
Copied
Replace the line
if (this.getField ("Site_Name"))
with
if (!this.getField ("Site_Name.Site_Name"))
Copy link to clipboard
Copied
Hi, see if this file works for you Link
Copy link to clipboard
Copied
Disregard post above, I uploaded wrong file but it doesn't allow me to edit post.
Try this New link
Copy link to clipboard
Copied
Thank you for trying, your version of the PDF worked but I then copied the script to my master PDF form and although this worked before having data pushed to it, after it had data pushed to it this nolonger worked. I would rather not post the full forms on here and wonder if you would like to take a look at both states of the form. I am willing to pay to get this one completed.
Copy link to clipboard
Copied
This is the latest version after data was pushed to it using the Script Nesa provided (which worked before data was pushed to it).
File Here
Copy link to clipboard
Copied
Replace the line
if (this.getField ("Site_Name"))
with
if (!this.getField ("Site_Name.Site_Name"))
Copy link to clipboard
Copied
This looks to be working now, thanks so much Bernd and Nesa.
I don't suppose many people will get into the same problem as me but I am posting the final script for reference.
if (!this.getField ("Site_Name.Site_Name"))
{
var tSite1 = this.getField("Site_Name").valueAsString;
var tSite2 = this.getField("C_Site_Name");
var tAddress1_1 = this.getField("Address_1").valueAsString;
var tAddress1_2 = this.getField("C_Address");
var tAddress2_1 = this.getField("Address_2").valueAsString;
var tAddress2_2 = this.getField("C_Address_2");
var tTown1 = this.getField("Town").valueAsString;
var tTown2 = this.getField("C_Town");
var tCounty1 = this.getField("County").valueAsString;
var tCounty2 = this.getField("C_County");
var tPostcode1 = this.getField("Postcode").valueAsString;
var tPostcode2 = this.getField("C_Postcode");
var tTelephone1 = this.getField("Tel_Number").valueAsString;
var tTelephone2 = this.getField("C_Telephone");
var tMobile1 = this.getField("Mobile_Number").valueAsString;
var tMobile2 = this.getField("C_Mobile");
}
else
{var tSite1 = this.getField("Site_Name.Site_Name").valueAsString;
var tSite2 = this.getField("C_Site_Name");
var tAddress1_1 = this.getField("Address_1.Address_1").valueAsString;
var tAddress1_2 = this.getField("C_Address");
var tAddress2_1 = this.getField("Address_2.Address_2").valueAsString;
var tAddress2_2 = this.getField("C_Address_2");
var tTown1 = this.getField("Town.Town").valueAsString;
var tTown2 = this.getField("C_Town");
var tCounty1 = this.getField("County.County").valueAsString;
var tCounty2 = this.getField("C_County");
var tPostcode1 = this.getField("Postcode.Postcode").valueAsString;
var tPostcode2 = this.getField("C_Postcode");
var tTelephone1 = this.getField("Tel_Number.Tel_Number").valueAsString;
var tTelephone2 = this.getField("C_Telephone");
var tMobile1 = this.getField("Mobile_Number.Mobile_Number").valueAsString;
var tMobile2 = this.getField("C_Mobile");
}
tSite2.value = tSite1;
tAddress1_2.value = tAddress1_1;
tAddress2_2.value = tAddress2_1;
tTown2.value = tTown1;
tCounty2.value = tCounty1;
tPostcode2.value = tPostcode1;
tTelephone2.value = tTelephone1;
tMobile2.value = tMobile1;