Skip to main content
Participant
October 22, 2020
Question

Adding identity name to dynamic stamp

  • October 22, 2020
  • 2 replies
  • 7253 views

I have created a stamp.  I have added the date through java script.  It works, but the identity name will not work with the code that I have.  I have had the person who made the code check it and it works for him, but not for me.  What am I doing wrong?

 

CODE:

if ((event.source.forReal)&&(event.source.stampName == "#AAN-ENG=MAIN"))
{
this.getField("Reviewer").value = identity.name;

 

Sandra

This topic has been closed for replies.

2 replies

Participant
August 7, 2024

I did a bunch of digging today through who knows how many channels and board and such, nothing helped.

I did find some code in the dynamic stamp that provided a starting point, but adjusted it slightly, which works!

ORIGINAL
event.value = (identity.name || (event.source.source || this).Collab.user);

UPDATE - simply adjusted collab.user to identity.name
event.value = (identity.name || (event.source.source || this).identity.name);

 

Hope this helps ya'll!

Thom Parker
Community Expert
Community Expert
October 22, 2020

For one thing, the code is missing the closing bracked, "}"

This is an error that will stop the code from working at all.

 

But also, the user must set the identity name. So it could be blank. To handle this situation, the built-in stamps use the "loginName" if the user hasn't filled out the identity parameters. Try this instead.

 

this.getField("Reviewer").value =  (identity.name && (identity.name != ""))?identity.name:identity.loginName;

 

And on another note. If this code is in the Calculation script on the "Reviewer" field, then do not use "this.getField". 

User this:

 

event.value =  (identity.name && (identity.name != ""))?identity.name:identity.loginName;

 

You can find out everything you ever wanted to know about scripting dynamic stamps here:

https://www.pdfscripting.com/public/All_About_PDF_Stamps.cfm

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
October 23, 2020

Thanks Thom.  It's still not working.  Identity name is filled out and here is the code that I used:

 

if ((event.source.forReal)&&(event.source.stampName == "#AAN-ENG=MAIN"))
{
event.value = (identity.name && (identity.name != ""))?identity.name:identity.loginName;
}

Thom Parker
Community Expert
Community Expert
October 23, 2020

Sounds like the "if" block may not be executing. Is the "#AAN-ENG=MAIN"stamp name correct. 

Maybe the name is "#AAN-ENG".  How did you check it?

Also, were any errors reported in the console window?

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often