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

Help with custom scripts

Community Beginner ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

Still pretty new to this, so, let's see if I can confuse everyone.  I don't have a lot of experience with custom scripts function in Acrobat.  But I'm having issues with a PDF and need help on creating a custom script for a couple of fields.  Any help would be greatly appreciated.  

 

My first issue is for the interest rate field.  When you enter the interest rate and set the format to percentage for the field, it forces the user to enter the decimal point before the number to get it to display correctly in the field.  So, is there a custom script that changes a whole number to a percent with the % sign or would it just be easier to hard code the % sign beside the field?  Current example- 8.00% needs to be entered as .008 to display correctly.

 

Second issue, after entering the interest rate in the above field, I need it to copy down to the to a duplicate rate field so it can be used to calculate the daily periodic rate field.  I thought I had this figured out but information does not automatically fill in until you tab or click through the fields.  Before I started messing with it, I had this script in the Custom Script on the Format tab.So, what, am I doing wrong.  Thank you!

 

if( event.willCommit ) {

    if(event.value == "") this.resetForm(["PURCHASE_APR1"]); else SetFieldValues(event.value); }

 

Here are the fields they fill in.

 

Interest Rates and Interest Charges:

 

Purchases:  0.00% Introductory APR for a period of six billing cycles.  After that, Your APR will be 8.00%.   (What you fill in here, should duplicate to the periodic rate section at bottom of form.)

 

Balance Transfers: 0.00% Introductory APR for a period of six billing cycles.  After that, Your APR will be 8.00%.

 

Cash Advances:  0.00% Introductory APR for a period of six billing cycles.  After that, Your APR will be 8.00%.

 

It should flow to this section.

 

Periodic Rates:

 

The Introductory Purchase APR is 0.00% which is a daily periodic rate of 0.0000% .

           (The Purchase APR should be pulled from the Interest Rate section and I have this custom script in the custom calculation script on the Calculation tab.  event.value = this.getField("INTRO PUR APR").value;)

           (Then for the daily period rate field, on the Calculation tab, I have a simplified field notation of INTRO PUR APR/365 and the format tab set to percentage with 4 decimal places.)

 

The Purchase APR is 8.00% which is a daily periodic rate of 0.0260% .

 

The Introductory Balance Transfers APR is 0.00% which is a daily periodic rate of 0.0000% .

 

The Balance Transfers APR is 8.00% which is a daily periodic rate of 0.0260% .

 

The Introductory Cash Advances APR is 0.00% which is a daily periodic rate of 0.0000% .

 

The Cash Advances APR is 8.00% which is a daily periodic rate of 0.0260% .

TOPICS
Create PDFs , PDF forms

Views

777

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 , Jul 28, 2022 Jul 28, 2022

To enter whole number and show as percentage and then to duplicate that to another field use this as validate script of percentage field and change "Duplicate field name" to your actual field name you want to copy value to:

if(event.value){
event.value = event.value/100;
this.getField("Duplicate field name").value = event.value;}
else
this.getField("Duplicate field name").value = "";

Votes

Translate

Translate
Community Expert ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

If you want help with your code you need to post the full code, as well as any error messages you're getting when you use 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 ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

The form is a CUNA form so I can't share it with the community as it's against their privacy regulations.  As far as the code, there is not any.  The script I posted in the original post is all I have and I found on the web.  I placed it in the custom scripts in the calculation tab in the form field properties.  Everything else is standard form field propeties.  Sorry, I told you I was new. 🙂

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 ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

Where's the definition of the SetFieldValues function, then? This is not a built-in function.

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 ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

Also, in the original question you wrote that you used the Format event, not the Calculate one, so which one is it? This is an important detail.

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 ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

Thank you!

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 ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

To enter whole number and show as percentage and then to duplicate that to another field use this as validate script of percentage field and change "Duplicate field name" to your actual field name you want to copy value to:

if(event.value){
event.value = event.value/100;
this.getField("Duplicate field name").value = event.value;}
else
this.getField("Duplicate field name").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 Beginner ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

That worked perfectly.  Thank you so much!!

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 ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

I do have one more question.  If I want to have it duplicate information to more than one field, would you have to write seperate statements or can you add the Duplicate field name separated by a comma?

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 ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

Just add another field like this:

if(event.value){
event.value = event.value/100;
this.getField("Duplicate field name").value = event.value;

this.getField("Duplicate field name2").value = event.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 Beginner ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

I thought it was something like that.  So you don't need the "else" statement, if you are copying to multiple 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 Expert ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

LATEST

No, you can add many fields as long as they are between curly brackets.

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 ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

Thank you for your help!!

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