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

Javascript & Dynamic stamps

marionboomsma
Registered: Jul 11 2008
Posts: 3

Hello,

I hope someone can shed a light on this one.

I want to make a custom stamp and did everything likeits descriped in this forum. That is that i copied the code from the normal dynamic stamp and pasted it into the custom calc. script of my own stamp.

However, only the time and date appear, and not the name.

I used this one:

event.value = (new Date()).toString();
AFDate_FormatEx("h:MM tt, mmm dd, yyyy");
event.value = "By " + ((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ? (event.source.source || this).Collab.user : identity.name)
+ " at " + event.value;

I filled out every field in the Identity fields.

What am I doing wrong?

My Product Information:
Acrobat Pro 8.1, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Do you have any JavaScript console error messages.

It appears you have only the date since the JavaScript fails when it comes to the object "event.source.source", which has no properties.

The code "!identity.name" is false unless this item is not completed

Have you tested the parts of your alternate "if" statement to see if it evaluates to a logical value?

console.show();
evemt.value = util.printd("h:MM tt, mmm dd, yyyy", new Date() );
console.println("Date: " + sTest);
console.println("identity.name: " + identity.name);
console.println("!identity.name: " + !identity.name);
console.println("identity.loginName: " + identity.loginName);
console.println("this.Collab.user: " + this.Collab.user);
console.println("event.source.source: " + event.source.source);
console.println("this).Collab.user: " + this).Collab.user);
console.println("event.source.source || this.Collab.user: " + event.source.source || this.Collab.user);

event.value = "By " + ((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ? (event.source.source || this).Collab.user : identity.name)
+ " at " + event.value;

George Kaiser

marionboomsma
Registered: Jul 11 2008
Posts: 3
Thank you for your quick response.

I don't quite understand your answer, but I tried out the JS debugger and it came with the following response:

this.ADBE has no properties
1:Doc:Exec
NotAllowedError: Security settings prevent access to this property or method.
Identity.name:3:Field G1:Calculate

As I understand it, there's some setting that prevents the stamp from doing what is said in the script.

How can I correct this?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
For certain newer versions there are security restrictions preventing accessing the identity object. I have posted a solution that works in Acrobat or LiveCycle Designer forms, [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=14045]use windows login name in textfield[/url]. The security restrictions and other details are contained in the [url=http://www.adobe.com/devnet/acrobat/javascript.php]Acrobat JS Reference[/url].

JavaScript runs until it has an error and then stops dead. So you could comment out those lines.

This line makes no sense at all
((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ?

"!identity.name" evaluates to false if the name property is filled in.

"identity.loginName != (event.source.source || this).Collab.user)" is not valid logical statement.

You cold try:

(identity.loginName != event.source.source.Collab.user) | (identity.loginName != this.Collab.user)

Compound logical statements are made up of very simple logical statements and their combined results are combined. You should be able to test each simple logical statement by itself.

console.println("identity.name != '': " + (identity.name != ''));
console.println("identity.loginName != this.Collab.user: " + (identity.loginName != this.Collab.user) );
console.println("identity.loginName != event.source.source.Collab.user: " + (identity.loginName != event.source.source.Collab.user) );

George Kaiser