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

Custom Calculation Scripts don't work in Adobe Reader

Community Beginner ,
Apr 23, 2024 Apr 23, 2024

Copy link to clipboard

Copied

Hi community experts,

 

I've created the following form (attached) with custom scripts using advice gathered from this forum and one or two others.

The scripts work perfectly fine in Foxit PDF, but won't function in Adobe Reader.

I am at a loss as to where to go next.

Any help will be gratefully appreciated.

TOPICS
JavaScript , PDF forms

Views

347

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

correct answers 1 Correct answer

Community Expert , Apr 24, 2024 Apr 24, 2024

Yes, it works fine for me once I make changes in Acrobat.

Your scripts are not registered in Acrobat because you probably create them in Foxit, you should recreate all scripting in Acrobat then it should work fine.

TIP:

Instead of using 14 different scripts you can update your script with a loop, so one script will calculate for all fields.

 

Votes

Translate

Translate
Community Expert ,
Apr 23, 2024 Apr 23, 2024

Copy link to clipboard

Copied

In this line:

var dateEnd = util.scand("dd/mm/yy h:MM tt,","01/01/23 " + F);

you have an extra comma after tt  remove it.

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 Beginner ,
Apr 24, 2024 Apr 24, 2024

Copy link to clipboard

Copied

Hi Nesa,

I removed the additional comma. It didn't make a difference, unfortunately. (see updated attachment)

I've got two scripts that should be running, the first autofills dates into the Date column, from the date you select for "Fortnight Ending", the second calculates the hours.

I suppose the first question is, do the calculations run for you? 

Could it related to a security setting on the local machine or Adobe Reader?

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 ,
Apr 24, 2024 Apr 24, 2024

Copy link to clipboard

Copied

Yes, it works fine for me once I make changes in Acrobat.

Your scripts are not registered in Acrobat because you probably create them in Foxit, you should recreate all scripting in Acrobat then it should work fine.

TIP:

Instead of using 14 different scripts you can update your script with a loop, so one script will calculate for all fields.

 

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 Beginner ,
Apr 24, 2024 Apr 24, 2024

Copy link to clipboard

Copied

Hi Nesa,

Thanks for the tip. I've created two loops, one for the date, the other for the hours worked. The date one works fine, but I'm not getting results with my hours worked. My code looks like this:

 

for(var x=1; x<15; x++){
var T = this.getField("Total"+x);
var S = this.getField("Start"+x).value;
var B = this.getField("Break"+x).value;
var F = this.getField("Finish"+x).value;

if(S && F){

var start = util.scand("dd/mm/yy h:MM tt","01/01/23 " + S);
var breaktime = B * 60000;
var finish = util.scand("dd/mm/yy h:MM tt","01/01/23 " + F);

{var diff = finish.getTime() - start.getTime() - breaktime;
var hours = diff/3600000;

if(diff < 0)
hours += 24;}

T.value = util.printf("%.2f",hours);}
else
T.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
Community Expert ,
Apr 25, 2024 Apr 25, 2024

Copy link to clipboard

Copied

Did you create it in Foxit?

When I delete script and put the same script again in Acrobat it works fine.

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 Beginner ,
Apr 25, 2024 Apr 25, 2024

Copy link to clipboard

Copied

LATEST

Yea, edited in Foxit, I'm waiting for approval for Acrobat.
Thanks for checking it, once I get Acrobat I know it'll work 🙂

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