Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Need a date field to be locked upon first signature

Avatar

Level 5

Hello,  Please help me find a solution to this.  I have a form that has a "current" date field.  I would like for that date field to be locked when the first signature block is signed.  I tried to use the action builder, but I could not figure it out.  If you can provide a script, that would be appreciated.

Thank you.

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi @islandgirl23,

I guess you used scripting for filling the date text field like so

kprokopi_1-1596199961243.png

When I call it without a signature the time is changed every time.

kprokopi_2-1596200005491.png

kprokopi_4-1596200108896.png

When I signed it the time stays

kprokopi_5-1596200217181.png

Place the date calculation inside an if such as this (status changes to 1 when the field has been signed).

 

if (event.target.getField("form1[0].#subform[0].SignatureField1[0]").signatureInfo().status == 0) {
  var datum = new Date();
  this.rawValue = datum.toISOString()
}

View solution in original post

5 Replies

Avatar

Level 10

You don't need a script. Just select the signature field and define a new collection under the Signature tab of the Object pallette. 

The collection defines those fields to be locked by the signaure.

 

radzmar_0-1594319026221.png

 

Avatar

Level 5
Thank you radzmar, but I tried that. The problem is that if you reopen the form after it's signed, the date the date field that is locked changes to the current date. Example: It's signed on Jun 20, 2020. If you open the document on July 10, 2020, the date field changes to July 10, 2020. Can you help me with that.

Avatar

Correct answer by
Employee

Hi @islandgirl23,

I guess you used scripting for filling the date text field like so

kprokopi_1-1596199961243.png

When I call it without a signature the time is changed every time.

kprokopi_2-1596200005491.png

kprokopi_4-1596200108896.png

When I signed it the time stays

kprokopi_5-1596200217181.png

Place the date calculation inside an if such as this (status changes to 1 when the field has been signed).

 

if (event.target.getField("form1[0].#subform[0].SignatureField1[0]").signatureInfo().status == 0) {
  var datum = new Date();
  this.rawValue = datum.toISOString()
}

Avatar

Level 5
actually, I have this script in the date field. form1.headersubform.HEADERS.todaydate::ready:layout - (FormCalc, client) $.rawValue = Num2Date(Date(), "YYYY-MM-DD"). Should I add an if calculation to this? Also, what does "datum.toISOtring() mean?

Avatar

Employee
datum.toISOString() is a quick way to display a datetime in a text field for testing with Javascript - it produces the string in my example. You can cut away the time part - but I used the full string as I cannot detect if the date has changed or not. This is JavaScript and should do the same as your script. Just I have it in the initialize script and not in ready.layout. reday.layout is not the most suitable event for this kind of calculations. If you want the date only with the ISO string then use this.rawValue = datum.toISOString().substring(0,10) - that gives you the same result as your FormCalc. So, try to remove your formcalc from read.layout and place my script in the initialize of your date field. Obviously you need to adapt the field name and SOM of the signature field to your values.