I'm using DC, and I have a form set up that I use as a template to create many versions of itself. At the moment, I open up the master form, fill in all the relevant details, and then hit a custom menu item that saves the master form as a copy of itself to a specified folder on my hard drive, naming it with concatenated data from some of the fields on it that I have just filled in, and in the process, closes the original master, having reset all the fields, leaving it clean and fresh to open another time when I want to create another copy. (Each copy contains information about various events that I am attending, and I need to know travel and accommodation details for each etc)
The master form also has a pdf attachment, which contains supplementary information regarding travel itinerary details pertaining to the event I am attending.
When the master form saves a copy of itself, it obviously includes a copy of the attachment along with it. This is exactly what I want it to do.
What I'm looking for is a way to populate the value of one of the fields on the attachment, at the same time as saving a copy of the master, so that when I open up the copy of the master, and click the button that launches the copy of the attachment, the new copy of the attachment will display the information from one of the fields on the parent file.
That's a lot of background information to say I can't find out or figure out a way to reference the field in the child file from the parent file.
I'm sure it will be something to do with changing the "this" in "this.getField("FieldOnAttachment");" but I don[t know what to change it to.
Any help will as always, be very gratefully received.
Copy link to clipboard
Open the attached form with the "doc.openDataObject()" function, which returns the document object for the attached PDF.
var oDocAttch = this.openDataObject("MyAttach");
oDocAttch.getField("BlaBla").value = "something";
As ever, Thom, I am in your debt. Thanks so much.
As a matter of interest, as I’m sure it will crop up before long, if I wanted to reference the a field in the parent document FROM a field in the attached off, what would be the process to find how to target it correctly?
Can't be done, At least not directly. There are strange context issues with referencing the parent document.
For example, you might think that a document script in the parent could place a reference to itself in a global variable. Then when the attachment is opened it could read and write data into the parent. Or that the document object could be grabbed from ActiveDocs (if the parent is "disclosed"), I tried all this back in version X, and all accesses threw errors.
However, these issue might not be a problem now. But even if it did work I wouldn't trust it for a long term solution.