Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Yes, well spotted. "position" is actually a built-in object in Acrobat JS, used for defining a button's layout setting.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
No, it should work exactly the same on both platforms.
Do you have an email account set up in Acrobat on the Mac, though?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more