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

livecycle designer close doc function (e.g. this.closeDoc();)

AndrewAlb
Registered: Aug 16 2007
Posts: 97
Answered

I am having trouble closing an xfa form using javascript.
Basically if a user opens xfa form in a version of acrobat less than what is acceptable then I want to close the form.

I have on my initialize event right now the following:

//////////////////////////////
if (xfa.host.version < 7.08 && xfa.host.variation == "Reader") {

var A = xfa.host.messageBox("We apologize but this form is only compatible with Adobe Reader version 7.09 or higher. We recommend that you update to the latest version of Adobe Reader (consult with your IT administrator first).\n\nClick \"OK\" to be directed to the Adobe Reader download page (Internet access is required.),"Version Not Supported",3,1)

if (A == 1)
app.launchURL("http://www.adobe.com/products/acrobat/readstep2.php",true);

this.closeDoc(true);
}

/////////////////////////////////////

I get an error on this.closeDoc(true); when it runs in the form.

I thought it would work since other AcroForm app methods work - e.g. like the app.launchURL - which does work in Designer.

I can't find anything in the Scripting Basics or anywhere else for xfa forms about hwo to do this.

To further confuse me - if I run it in the console while that form is open the form closes as expected. Which leads me to believe that it should work in the initialize event.

So what am I to do....?

I googled this topic and googled it and googled it but can't find an answer.

Any help would be appreciated.

-Thanks!

Andrew D. Albrecht, MS
Solutions Developer
ING USFS

My Product Information:
LiveCycle Designer, Windows
almitche
Expert
Registered: Apr 1 2008
Posts: 41
Hi there,

I think you almost have it, the problem is just syntactical. In Designer, you can reference Acrobat JavaScript, but Designer needs to know more about what you are referencing.

See this Designer Help topic: Scripting > Scripting Using LiveCycle Designer ES > Moving from Scripting in Acrobat to LiveCycle Designer ES > Using JavaScript objects from Acrobat in LiveCycle Designer ES.Click F1 when Designer is running and then browse to that topic.

From the help: In LiveCycle Designer ES, use event.target to access the Doc JavaScript object from Acrobat. In Acrobat, the this object is used to reference the Doc object; however, in LiveCycle Designer ES, the this object refers to the form design object to which the script is attached.

So I think what you need to do is change this.CloseDoc(true) to:

var myDoc = event.target;
myDoc.closeDoc(true);

That works for me.

Hope that helps.

- Alex
AndrewAlb
Registered: Aug 16 2007
Posts: 97
I will check that out. Thank you very much!


Worked perfectly! Thanks again.

Andrew D. Albrecht, MS
Solutions Developer
ING USFS