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

Getting url used to access to a form

Jean-Yves
Registered: Jan 24 2008
Posts: 5
Answered

Hello everybody ,

I use Adobe livecycle 8.0 to make some form.
I would like to get the url used to access to a pdf form.

I found on Stefan Cameron blog this script :

...
var sURL = event.target.URL; // URL used to access this PDF form
...

But when I insert this script in my form a security message occurs because i think "event.target.url" call an event to launch again the URL in my form.

Can anyone can help me to find an other way to get the URL used to open my form ?

Thanks in advance .

Jean-Yves

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
What error are you getting? Is the event you are using set to JavaScript?

This code should work in any JavaScript context within LiveCycle Form.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Jean-Yves
Registered: Jan 24 2008
Posts: 5
I have a security error :

I have translated the error text (it is a french version of acrobat) :

Security Warning :
Acrobat is triyning to connect to website :
fle:///s:/test.pdf?LotFe=04505050

If you trust in this website , click on Grant button else click on Deny.


I set Javascript regarding this event.

If I remove the line : "var sURL=event.target.URL;" the security warning desapear.

Thanks in advance
dk3dknight
Registered: Jan 22 2008
Posts: 136
Most likely this is a warning telling you that acrobat is trying to access a website, this merely to warn a user in case he did not intentionally plan to go to said website.

Alot of times malicious people will take people to fake websites in attempts for phising for data.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The line of code:

var sURL = event.target.URL; // URL used to access this PDF form

is not causing this warning message. All it is doing is assigning one string to another string. There has to be more going on. And when you remove it your probably causing an exception in the following code. Look in the JavaScript Console. What errors are reported there.

Are you trying to submit or save data? The address in the error message is for a local file, which makes sense, since you are working on this file. What are you trying to do?

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Jean-Yves
Registered: Jan 24 2008
Posts: 5
In my form I want to populate field with some data stored in Sql Server 2000 database.
The table contains many records and I need to select one with the primary key.

I found on the StefanCameron Blog this article :
http://forms.stefcameron.com/2006/10/20/using-url-requests-in-pdf-forms
in which he explains how to pass parameters to a form.

I have created a form with a Database connection (name = "LAGPAO")
I have also added a Variable form named LotFE . This variable helps me to pass query parameter between initialize (Javascript) event to form ready (Formcalc) event .

So here is the code I wrote :

----- topmostSubform::initialize: - (JavaScript, Client) -------------------------------
var sURL = event.target.URL; // getting URL
var nRequestStart = sURL.indexOf("?");
var sRequest = sURL.substr(nRequestStart + 1);
var aNameValue = sRequest.split("=")
LotFE.value=aNameValue[1]; // getting parameter value and

----- topmostSubform::ready:form - (FormCalc, Client) ------------------------------
var oDC = Ref(xfa.sourceSet.LAGPAO.clone(1));
oDC.#command.query.select=concat("select * from tblLotFrontEnd where NumLotFe='",LotFE,"';");
oDC.open();

I have 1 warning when I save this pdf :
the script failed (language is javascript ; the context is xfa[0].form[0].topmostSubform[0])
script=var sURL = event.target.URL;
xfa.host.messageBox(sURL,"Paramètre du PDF",3);
var nRequestStart = sURL.indexOf("?");
//xfa.host.messageBox(String(nRequestStart),"test",3);
var sRequest = sURL.substr(nRequestStart + 1);
//xfa.host.messageBox(sRequest,"essai",3);
var aNameValue = sRequest.split("=")
LotFE.value=aNameValue[1];
Erreur : null is not an object


Thanks again.

Jean-Yves
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
It looks like the "oDC.open()" could be the problem. I don't know what to do about that, but it also seems like there are possibly more problems here.

You have a lot of code and your going to have to debug it yourself. But I can give you some pointers.

First off, there is a lot of string manipulation and no checking to see if the strings results are actually valid. It looks like you did some checking with message boxes, but there should be null string testing in the code.

Use console.println() statments to display the variables at each point where there could be a problem. This will give you a better idea of what's happening.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

sconforms
Expert
Registered: Jul 10 2007
Posts: 92
Jean-Yves,

I believe the problem here is that you're attempting to use the event.target.URL property when simply viewing the PDF in your browser, opened from your local file system. There must be some security layer in Acrobat that's stopping the form's access to the file name and path since the path could contain, for example, your user id (as in "C:\Documents & Settings\{userid}\My Documents\myForm.pdf"). Acrobat is asking you if you trust the website (the PDF) to access this private information.Based on

Jean-Yves wrote:
Security Warning :
Acrobat is triyning to connect to website :
fle:///s:/test.pdf?LotFe=04505050
that's what's happening.

The sample form on my blog on [url=http://forms.stefcameron.com/2006/10/20/using-url-requests-in-pdf-forms]accessing the URL Request[/url] is really meant to be used within a web server environment (e.g. IIS, Apache, etc.). I would suggest running your tests using a local web server.

Stefan Cameron obtained his bachelor's degree with Honors in Computer Science at the University of Ottawa and is a Computer Scientist working on Adobe's LiveCycle server products, in particular on LiveCycle Designer ES for the past 5 years.

Jean-Yves
Registered: Jan 24 2008
Posts: 5
Hello Stefan ,

Thank you for your explanation .
I can not put ours Livecycle forms in a web server , they are stored on a network share.

I used this way for passing parameter to a Livecycle Form .

Do you think that there is another way to pass parameter between a VB application and a Livecycle Form without using a web server ?

Thanks again.

Jean-Yves