Skip to main content
Participant
July 2, 2018
Question

Dynamic Stamp returning null for event.source

  • July 2, 2018
  • 2 replies
  • 4007 views

I am trying to create a custom dynamic stamp in which the user is prompter to enter information when the stamp is placed.

Here is the code I am using:

var cAsk = "Please enter Inspection Date";
var cTitle = "Inspection Date";

if(event.source.forReal &&
   (event.source.stampName == "#-65c2ZoyHu7QwjOp-fjeqA"))
{
   var cMsg = app.response(cAsk, cTitle);
   cMsg += util.printd("mm/dd/yyyy", new Date());
   event.value = cMsg;
   event.source.source.info.DocumentState = cMsg;

}

However I keep getting the error: event.source is null.

Help!!

This topic has been closed for replies.

2 replies

PDF Automation Station
Community Expert
Community Expert
July 3, 2018

Your script should work.  However, you will always get the error "event.source is null" in the console after you add or change the script because the script runs when you close the field properties box and event.source will be null until you apply the stamp.  Also, do the end users all have Acrobat Pro or Standard?  Your script won't work with Reader because you can't write custom metadata.

ecohen19Author
Participant
July 3, 2018

All the end users have Acrobat Standard, so it should work right? The people viewing the PDFs with the stamp might only have Reader but that should not make a difference, correct?

try67
Community Expert
Community Expert
July 3, 2018

Yes, that's correct, but I would recommend simply removing that line altogether. Someone added it to some sample code a long time ago and people keep copying and using it, even though it's not necessary at all and just complicates things.

try67
Community Expert
Community Expert
July 2, 2018

Change this:

if (event.source.forReal && (event.source.stampName == "#-65c2ZoyHu7QwjOp-fjeqA"))

To:

if (event.source && event.source.forReal && (event.source.stampName == "#-65c2ZoyHu7QwjOp-fjeqA"))