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

Get Windows account and use a list in Sharepoint with JavaScript

Horn33t
Registered: Aug 27 2009
Posts: 20

Hi,
I'm currently making forms, and I'm trying to add some JavaScript code in them in order to automatically fill two fields : the name and the last name.
The procedure is as following : the form has to recognize who is logged on windows, get the login, and then go and pick up in a SharePoint list the name and the last name corresponding to the login.
Then, I have two questions :
- How can I get the login of the person who is logged
- How can I connect the pdf form to a Sharepoint Server and then get informations from a list.
Thanks a lot.
Horn33t.

My Product Information:
Acrobat Pro 9.1.3, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
You will have to use Acrobat's 'identity' object to access the 'loginName' property. Begriming with version 7, Adobe has restricted access to the identity object to batch, console and initialization actions. So you will need to create application level JavaScirpt to capture this information or create a folder level trusted function to obtain this data. And the folder level JavaScript will need to be added to every user's system. This technique will also work with Reader.

You can use the 'search' feature to find more references to the 'identity' object.

You will need to post the the PDF form to a library on the SharePoint server. Acrobat, not Reader, can access an SQL data base, which SharePoint should be able to support.

George Kaiser

Horn33t
Registered: Aug 27 2009
Posts: 20
OK thanks a lot, I'll try this.
Horn33t
Registered: Aug 27 2009
Posts: 20
Could you precise me what is an application level Javascript and how to create it?
And what about a folder level ?
Thanks a lot.
Horn33t
Horn33t
Registered: Aug 27 2009
Posts: 20
There's something that I don't understand : how can I create a separate application JavaScript that I have to install on every computer although JavaScript can not be run "alone".Do I have to make links between the separated application and my PDF file ? How can I make them ? Thanks a lot.
Horn33t
Horn33t
Registered: Aug 27 2009
Posts: 20
Fortunately I managed to find alone, because I don't think that I could have got help before Christmas.
In fact there are some methods and objects that cannot be runned (into a mouse event for example) for security reasons. The way to run those objects is to put the code into a separated .js file that you move into a special folder. There are two special folders : the local one and the global one. They can be found by typing app.getPath("user","javascript") or app.getPath("app","javascript") in the javascript console. Normally you can open the Javascript console with Ctrl+J on Windows, but it didn't work on my computer (for obscure reasons ... ). Thus, to open the console window, I wrote a function that creates an error :

myTrustedSaveAs = app.trustedFunction(
function(adoc)
{
app.beginPriv();
var myTrustedRetn = adoc.saveAs({
cpath: "/C/Documents and Settings/jdawson/My Documents/Test/doc_ver8.pdf",
bPromptToOverwrite: False
});
app.endPriv();
return myTrustedRetn;
}
);

in a mouse event on one of my button.
Then, the console window opens, I juste have to clear the console to make things clear, and type my command. If you type enter, you will make a new line, but if you type Ctrl+Enter, it executes the command.
That's what you need to run Trusted functions.
I hope I has been clear enough :)
Bye
Horn33t
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
[url=http://www.acrobatusers.com/tutorials/2006/folder_level_scripts]Entering Folder Level Scripts[/url] by Thom Parker explains and provides links for additional information on how to create and place JavaScirpts.

[url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=18384]How to Capture UserID and Add to Form[/url] shows how to create an application level JS to capture the identity object information or create a trusted function to obtain the data.

Many responders are just users like yourself, and are not paid nor receive any special favors from Adobe, and respond on their own time. And we are sorry our schedule does not provide for immediate response to your questions.

George Kaiser

Horn33t
Registered: Aug 27 2009
Posts: 20
Yes I'm sorry I was a bit angry last weak because I was blocked for days and days and noone seemed to help me ...
By the way thanks a lot for your answer.
In fact I really want to connect to a sharepoint list because there are other fields such as "phone number" that we can't find with the identity object. Moreover, I think that the sharepoint list is the only one that is updated.
Do you think it would be possible to incorporate some C# code in order to connect to the sharepoint list?