Why isn't my java working?
Copy link to clipboard
Copied
Can anyone tell me why my js is not working? I have the same data on two different .pdf. I want to be able to have someone fill in the forms on a screen and press a button to open and populate the other .pdf with that information that is entered. Nothing I seem to do is working. I made sure all my fields were named the same. Can anyone help? Please.
This is the script.
this.slave=app.openDoc("IKO Proposal.pdf",this);
this.bringToFront();
for (var i=0; i<6; i++){
var FLIKOProposalformData = this.getField("FLIKOProposalform."+i);
var IKO_ProposalData = this.slave.getField("IKO_Proposal."+i);
IKO_ProposalData.value = FLIKOProposalformData.value;
}
slave.bringToFront();
Copy link to clipboard
Copied
java != javascript
Copy link to clipboard
Copied
in the future, to find the best place to post your message, use the list here, https://community.adobe.com/
p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.
<"moved from using the community">
Copy link to clipboard
Copied
Check the Javascript console for errors.
Copy link to clipboard
Copied
You need to save a reference to the current document using something other than the "this" object, as the new file you're opening will take over it once loaded. Also, I don't think the bringToFront method works any longer.
Copy link to clipboard
Copied
Hi! Thank you for the response... however... i have absoltuley no clue how to fix the "this" object... I was watching tutuorials online and that is what they had, I just adjusted it to my file names. Same with the bringToFront method... I was just hoping someone could help me either rewrite or tell me where errors are.
Copy link to clipboard
Copied
Try this code:
var primaryDoc = this;
var secondaryDoc = app.openDoc("IKO Proposal.pdf", primaryDoc);
for (var i=0; i<6; i++){
var FLIKOProposalformData = primaryDoc.getField("FLIKOProposalform."+i);
var IKO_ProposalData = secondaryDoc.getField("IKO_Proposal."+i);
IKO_ProposalData.value = FLIKOProposalformData.value;
}
Copy link to clipboard
Copied
Hi!
Thank you! unfortunately it still doesn't work, I can upload the docs if you'd like, b/c I have like 5 or 6 different ones that I will be trying to do like this. When I type it in the FLIKOProposalForm and click on the "Generate Invoice" button that I have created to open the IKO Proposal form none of the information transfers, even with this code.
Copy link to clipboard
Copied
You need to check the JS Console. The openDoc method, for example, will not return an object if used from a button.
Copy link to clipboard
Copied
this?
Copy link to clipboard
Copied
No. Press Ctrl+J to open the Console after you run the code.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
One or the field names you're trying to access doesn't exist.

