Skip to main content
Participating Frequently
August 8, 2023
Question

Help with Extracting Signature Name for email message body.

  • August 8, 2023
  • 1 reply
  • 617 views

Hi All,

I am trying to extract the name of the last person to sign a form, to then use that name to include in an email message body.

Years ago I had it working comparing 3 possible signatures on my form. I later changed it to only 2 signatures but I can no longer get it to extract the name. I understand that it might not work 100% of the time depending on the time zone of the signing user.

My logic is : compare the timestamps to find the most recent - hoping that the most recent should be the person that hit the "send" button after signing the form. 

So grab that name and drop it in the email message body.

My code... (and it might not be the most efficient - I am not so good at programming.

This code is in the Send button of the form under Mouse Up.

var sign1 = this.getField("Signature1");
var sign2 = this.getField("Signature2");

// get signature timestamps & names
var sigInfo1 = sign1.signatureInfo();
var sigInfo2 = sign2.signatureInfo();
var dt1 = sigInfo1.date;
var dt2 = sigInfo2.date;
var finalName = "";
var position = 0;

if (dt1 < dt2){
  finalName = sigInfo2.name;
}
else{
  finalName = sigInfo1.name;
}

//extract just the name which should be before 
//the < of the email address in a self-issued signature in Adobe

position = finalName.indexOf("<");
if (position >= 0){
   finalName = finalName.substring(0,position);
}
else{
   finalName = "...";
}

cMessBody = cMessBody + "\u000D \u000DRegards, \u000D" + finalName;

 

Currently my code always ends-up with the finalName being "..."

Thanks,

Dan

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 8, 2023

That would indicate that the value does not contain the "<" character. Maybe there's no email address associated with the profile? I recommend printing out the value of finalName to the console, so you can see what you're working with.

DanMovieAuthor
Participating Frequently
August 8, 2023

Thanks.  Could it be as stupid as "position" is a reserved word ?

I just changed it to "place" and it seems to work in my test script.

try67
Community Expert
Community Expert
August 11, 2023

Yes, well spotted. "position" is actually a built-in object in Acrobat JS, used for defining a button's layout setting.