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

Auto Fill Doc ads "$" before a number and breaks my calculation. Can this be fixed?

Community Beginner ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

I am trying to create a payment schedule change document and have the field auto-fill from our CRM platform.  I do not have the ability to change how the CRM exports values. 

 

In the preview of documents, the CRM only brought in a number, e.g. 5000.  In the live version of the same export, it brings in a "$" or $5000 into the field.

 

This "$" results in my calculation returning NaN

The calculation I am using is: 

v1 = getField("JobBalanceDueAmt").value;
v2 = getField("Adjustment").value;
event.value = v1 - v2;

 

How can I make the calculation ignore the currency symbol and return an answer that is not NaN?

Thank you for any help!

Best, 

 

-Anthony

TOPICS
JavaScript

Views

2.2K

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 , Dec 07, 2022 Dec 07, 2022

There's no "$" character in the sample you provided, but a comma, which also will cause the same thing.

To solve both issues adjust your code like this:

 

var v1 = this.getField("JobBalanceDueAmt").valueAsString.replace(/[\$,]/g, "");
var v2 = this.getField("Adjustment").valueAsString.replace(/[\$,]/g, "");
event.value = Number(v1) - Number(v2);

Votes

Translate

Translate
Community Beginner ,
Dec 06, 2022 Dec 06, 2022

Copy link to clipboard

Copied

Why can't I get any love and help here?

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
LEGEND ,
Dec 06, 2022 Dec 06, 2022

Copy link to clipboard

Copied

I don't really understand the issue (I mean, I see you have an issue but I don't see what you are doing, so I can't suggest anything to help).

How do you "auto fill" with data from the CRM. What software or method do you use to "auto fill", exactly?

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 ,
Dec 06, 2022 Dec 06, 2022

Copy link to clipboard

Copied

The CRM is browser-based.  I create templates with "Smart Tags."  These tags place values in the fields of the PDF.  
The issue I am having is the preview/test export from the CRM, the number comes out without the "$" symbol e.g. "12345".  When we use the live version, it comes out with the "$" symbol.  

When it doesn't have the $, the formula works.  When it comes out with it, it does not work. 

Please let me know any other questions you have.  Happy to answer. I also attached the document to the post. 

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
LEGEND ,
Dec 06, 2022 Dec 06, 2022

Copy link to clipboard

Copied

Now, I hadn't heard of smart tags, but I see they might something to do with Adobe Experience Manager (AEM). So, before we go any further, my question is how you are making the forms. Are you using Acrobat Pro? Or AEM Designer? Or something else?  

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 ,
Dec 06, 2022 Dec 06, 2022

Copy link to clipboard

Copied

Smart tags may just be what the CRM, which is a proprietary product, calls them. 
I take a PDF that I make in Adobe Acrobat Pro, and name the fields with the appropriate smart tag for the value I would like the CRM to export in that field.  I upload that into the CRM as a template.  Then when we are in any job, we can generate that PDF template in a tab called "letters" and it comes out auto-filled. 

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 ,
Dec 06, 2022 Dec 06, 2022

Copy link to clipboard

Copied

I can also make a screen recording if you think that would 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
Community Expert ,
Dec 07, 2022 Dec 07, 2022

Copy link to clipboard

Copied

The issue in your sample is the comma of 8,000.00

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 ,
Dec 07, 2022 Dec 07, 2022

Copy link to clipboard

Copied

There's no "$" character in the sample you provided, but a comma, which also will cause the same thing.

To solve both issues adjust your code like this:

 

var v1 = this.getField("JobBalanceDueAmt").valueAsString.replace(/[\$,]/g, "");
var v2 = this.getField("Adjustment").valueAsString.replace(/[\$,]/g, "");
event.value = Number(v1) - Number(v2);

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 ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

LATEST

TYTYTYTYTYTYTYTYTY!!!!!

I actually tried to use ChatGPT but was not succeeding.  I remembered I started this thread and came back for a visit.  Your answer is working!  I am not 100% sure on why my example is not producing the correct output with the "$".  The export has both the "$" and "," coming for values larger than 4 digits.  

Thank you for your generosity with your time and knowledge with everyone that took the time to help.  I really appreciate it and I learned something! 

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