Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
2

Help with Extracting Signature Name for email message body.

Community Beginner ,
Aug 08, 2023 Aug 08, 2023

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

TOPICS
JavaScript , PDF forms
632
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2023 Aug 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 08, 2023 Aug 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 11, 2023 Aug 11, 2023

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 11, 2023 Aug 11, 2023

Thanks.

Can I ask a quick sort of related question.... this code is attached to a button to send an email.

As I was testing with people using a MAC, I am told the button does nothing. Is there a conversation process that must be done for stuff done on a PC to work on a MAC ?

 

Thanks,

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 11, 2023 Aug 11, 2023
LATEST

No, it should work exactly the same on both platforms.

Do you have an email account set up in Acrobat on the Mac, though?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines