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

Applying argument to multiple fields

Community Beginner ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

Is there a way to apply the following code to multiple fields? In other words, could this be set as document level code that applies to multiple fields instead of having the code in each form field? My form is getting sluggish, it take 4-5 seconds after filling in data to tab to the next field, so I'm trying to cleanup the code. 

 

var TotalTime=this.getField("GRAND TOTAL").value;

if(event.value>TotalTime)app.alert("Cannot Exceed Total Time")

 

if (event.value==0.0) event.value = "";

 

//This code is in fields “1 Time”, “2 Time”, “3 Time”, etc.

TOPICS
How to , JavaScript

Views

697

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 2 Correct answers

Community Expert , Feb 25, 2021 Feb 25, 2021

Yes you can do that, but if your PDF is sluggish it won't make a difference if you call the function from those fields as a custom calculating script.

 

Instead, you should call the function with a mouse-up event action or Custom Keystroke Script. Doing so will only call the function and execute the script when is really needed instead of a a script looping in the background continuously when used a custom calculation.

 

For example, if the GRAND TOTAL field is the field that contains some heavy

...

Votes

Translate

Translate
Community Expert , Feb 25, 2021 Feb 25, 2021

Under what event did you place this code? Assuming it's a Validation script, that's not what causing your form to be sluggish, as it only executes when you change the field's value. Calculation scripts are typically what causes that, as they are executed when the value of any field in the file is changed.

Votes

Translate

Translate
Community Expert ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

Yes you can do that, but if your PDF is sluggish it won't make a difference if you call the function from those fields as a custom calculating script.

 

Instead, you should call the function with a mouse-up event action or Custom Keystroke Script. Doing so will only call the function and execute the script when is really needed instead of a a script looping in the background continuously when used a custom calculation.

 

For example, if the GRAND TOTAL field is the field that contains some heavy calculations use that script as a document-level function oand call that function from that field with a mouse-up event. The user must click inside and outside the GRAND TOTAL field to execute the calculation though.

 

Then the code that you posted here use it as a validation script instead of a custom calculating script.

 

These are just ideas.

 

Everyone has different approaches or knowledge on how to obtain similar results.

 

In my case, as I am learning JavaScript, that is what I do in my forms. 

 

Using a combination of fields with mouse-up events, checkboxes, dripdown menus, and custom keystroke script can make the PDF fly. You would be surprised with the speed.

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 ,
Mar 02, 2021 Mar 02, 2021

Copy link to clipboard

Copied

Thank you for the information! I am super new to JavaScript but evrything you mentioned makes sense. I just need to learn how to apply document level script and how to call functions. 

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 ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

Under what event did you place this code? Assuming it's a Validation script, that's not what causing your form to be sluggish, as it only executes when you change the field's value. Calculation scripts are typically what causes that, as they are executed when the value of any field in the file is changed.

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 ,
Mar 02, 2021 Mar 02, 2021

Copy link to clipboard

Copied

I'm a novice, so I'll try to answer your question as best as possible. The code is in the Validation script of fields "1 Time”, “2 Time”, “3 Time”, etc. However, there are a lot of other fields that have script in Custom Calculations which it sounds like I should move to Validation, when possible. 

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 ,
Mar 02, 2021 Mar 02, 2021

Copy link to clipboard

Copied

LATEST

Calculation and Validation are quite different, but if you can move code from the latter to the former it will help your form work faster, yes.

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