Skip to main content
buddycafe
Known Participant
October 25, 2017
Question

Date field populates with today's date when Signature signed via sigpad

  • October 25, 2017
  • 1 reply
  • 453 views

Hello,

I'm able to populate today's date to a single field by inserting this script to the Signature field.

this.getField("Datefield1").value = util.printd ("m/d/yyyy", new Date());

How can I do an "OR" to the above script so I can insert 5 fields? Reason being is the naming convention of the date field can be five different names.

Datefiled1

Datefiled2

Datefiled3

Datefiled4

Datefiled5

Instead of going into the script and edit the Datefield, I just want the script to work for any of the five.

I tired this but no luck....

this.getField(("Datefield1")||("Datefield2")).value = util.printd ("m/d/yyyy", new Date());

Thank you

Ed

This topic has been closed for replies.

1 reply

Inspiring
October 25, 2017

The "||" is the logical OR operator and is used in logical expressions. You can not use it for a field name in the getField method. Logical expressions are statements the evaluate to either a logical value of true or false.  The logical OR statement is used to evaluate the result of two logical statements to one logical value. Following is the truth table for the logical OR.

OR    |  true  |  false |

-------+--------+--------+

true   |  true  }  true   |

-------+--------+--------+

false |  true  }  false  |

-------+--------+--------+

If either statement or both statements are true the result is true. The false value is only possible if both statements are false.

I would create a variable with the current date and then assign that variable's value to each date field.

buddycafe
buddycafeAuthor
Known Participant
October 25, 2017

Thanks for the reply gkaiseril

The problem I have with setting a variable with a current date is because the variable must be unique (up to five) depending on the content of the form. To clarify 'unique', these variables are going to be captured by vendor when the form is submitted via API interface. The vendor identifies if it's either Field1, Field2, Field3, etc and processes this form on their end.

Rather than constantly editing the script in the signature field, I'm hoping a script can be written in such a way that it responds on the condition that the date field are any of the five variables noted above. Hope this makes sense.

try67
Community Expert
Community Expert
October 25, 2017

Your condition is not very clear... Based on what do you want to decide which field to populate, exactly?