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

Need Help Creating calculations coluns

Community Beginner ,
Sep 25, 2023 Sep 25, 2023
Hello everybody,

I'm new to using Adobe Acrobat and I'm very confused. I want to convert an old timesheet made in Excel into a fillable form in Adobe Acrobat.
This calculation must demonstrate the number of hours between a starting time and an ending time, in short the employee will fill in their overtime, 6:35pm - 7:55 = 1.2h.

Currently I managed to do this using the following script:
event.value = - ( this.getField("start1").value - this.getField("end1").value)

However, this pdf is sent already filled out to be signed through a flow, which sends it to email, it is signed by Adobe Acrobat Sign, and the result is coming in the wrong way.

Result in the image..

1- result when filling out
2-result adobe sign
result adobe sing.pngresult when filling out.png 

 

Can anyone help me with this, any ideas would help, thank you.

 

TOPICS
Edit and convert PDFs , How to , JavaScript , Modern Acrobat , PDF , PDF forms
815
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
1 ACCEPTED SOLUTION
Community Expert ,
Sep 26, 2023 Sep 26, 2023
LATEST

When an existing AcroForm (regular PDF form) is sent for signatures, the regular form fields are flattened out. Only fields with the Adobe Sign markup names are preserved. So prefilling works for sending a regular AcroForm for signatures.

 

Now you need a script for calculating the time difference.   

 

This thread provides two variations on one method:

https://community.adobe.com/t5/acrobat-discussions/timesheet-to-display-worked-hours-minutes-as-hour...

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

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 ,
Sep 25, 2023 Sep 25, 2023

The result is wrong anyway.  22:55 - 21:35 is 1 hour and 20 minutes, which is 1.33 hours. 

Times are very different from regular decimal numbers, and have to be handled differently. 

You'll find a very large number of posts here on time difference calculations that provide a variety of methods for peforming this type of calculation.  

 

The other problem is about number representation. Ignore this. If you get the time calculation correct, then the values in the fields will be text, so number formatting will not affect the display.  

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Sep 25, 2023 Sep 25, 2023

Also, scripts stop working when you convert the file to Acrobat Sign. You can't have both things working at the same time. Switch to regular digital signatures if you want your calculations to work.

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 ,
Sep 26, 2023 Sep 26, 2023

Thanks for the answer.

 

If I fill it out first, what is the best script for this? This way, the document would already be filled in (webB) with the starting and ending times. Then it could be converted to the already completed ABsign, only being reviewed and signed.

 

Could this be an alternative?

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 ,
Sep 26, 2023 Sep 26, 2023
LATEST

When an existing AcroForm (regular PDF form) is sent for signatures, the regular form fields are flattened out. Only fields with the Adobe Sign markup names are preserved. So prefilling works for sending a regular AcroForm for signatures.

 

Now you need a script for calculating the time difference.   

 

This thread provides two variations on one method:

https://community.adobe.com/t5/acrobat-discussions/timesheet-to-display-worked-hours-minutes-as-hour...

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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