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
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);
Copy link to clipboard
Copied
Why can't I get any love and help here?
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?
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.
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?
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.
Copy link to clipboard
Copied
I can also make a screen recording if you think that would help.
Copy link to clipboard
Copied
The issue in your sample is the comma of 8,000.00
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);
Copy link to clipboard
Copied
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!