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

Converting signatureInfo() elements to a string

New Here ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

I'm trying to extract elements of the date on a signature and convert them into a string.  I can extract the date/time element from a digital signature, but I can't seem to then convert that to a string.

The following script is run when the document is signed:

 

var f = this.getField("Signature1");

var Info = f.signatureInfo();

var d = Info.date; this.getField("Text1").value = d; //Works fine up to this point

var z = d.valueAsString;

this.getField("Text2").value = Left(z,5)

 

I have even tried replacing the last line with this.getField("Text2").value = z and get nothing?

 

Any assistance would be greatly appreciated.

 

The text box returns no value

TOPICS
How to , JavaScript

Views

689

Translate

Translate

Report

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
LEGEND ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

Why do you use valueAsString? And why do you say you want to convert it to a string? Surely it's already a string? What value does it have?

Votes

Translate

Translate

Report

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
New Here ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

I think my problem may have been answered in the next post.  If there is no Mid, Left or Right in JS then that would explain it, although why I didn't get an error is a bit puzzling.

Votes

Translate

Translate

Report

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
New Here ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

I am running the script when the document is signed.  Would that matter? 

Frustratingly, I solved the problem and managed to write the information I extracted to another text box using substring.  I then tried to do all the calculations without using the first text box and now I can't remember what I did originally.  

 

This script is run when the document is signed:

var f = this.getField("Signature1");

var Info = f.signatureInfo();

var d = Info.date;

this.getField("Text1").value = d;

 

No problem to this point and from there I calculate the next field using the script

 

var r = this.getField("Text1").substring(11,24);

this.getField("Text2").value = r

 

Nothing comes up in the second text box.  I'm guessing it is my syntax when defining 'r'.

Votes

Translate

Translate

Report

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 ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

You're missing something important here:

var r = this.getField("Text1").substring(11,24);

You need to access the field's value...

Votes

Translate

Translate

Report

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
LEGEND ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

You shouldn't have to guess. There should be an error message. Do you have the console open to check for them? Nothing will pop up if your code is wrong.

Votes

Translate

Translate

Report

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
New Here ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

Thanks for your help - I managed to get it working.  I'm not sure how to open the console?  I am writing the script using Adobe Acrobat and placing it in the fields in the form.

Votes

Translate

Translate

Report

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 ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

LATEST

Ctrl+J will open it. You should also enable the option to show it automatically when there are errors. This setting can be found under Edit - Preferences - JavaScript.

 

Under what event did you place the code, exactly?

Votes

Translate

Translate

Report

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 ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

There's no function in JS called Left. Did you define one yourself?

Votes

Translate

Translate

Report

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
New Here ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

That would explain it.  I am new to JS and assume there are Left, Right and Mid functions.  Thanks for that.

Votes

Translate

Translate

Report

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 ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

It would have. Something like this:

 

ReferenceError: Left is not defined

 

[Edit: this was meant as a reply to your other reply, about not getting an error message...]

Votes

Translate

Translate

Report

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