Skip to main content
Participating Frequently
November 10, 2022
Answered

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

  • November 10, 2022
  • 4 replies
  • 3036 views

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

This topic has been closed for replies.
Correct answer try67

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);

4 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 7, 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);

Participating Frequently
December 19, 2022

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! 

Bernd Alheit
Community Expert
Community Expert
December 7, 2022

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

Legend
December 6, 2022

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?

Participating Frequently
December 6, 2022

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. 

Legend
December 6, 2022

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?  

Participating Frequently
December 6, 2022

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