Copy link to clipboard
Copied
Hi,
I have a column on a document that autosums all the numbers in it in the bottom cell (image attached).
Sometimes this form is filled out for figures in pounds sterling(£) and sometimes in Euro(€).
Is it possible to have whatever currency symbol I enter in the rows appear in the autosum total at the end. For example if I start entering amounts with a £, the autosum cell will have a £ and vice versa for €.
Note: The rows never deal with mixed currency, it is always either one or the other.
Thanks
Copy link to clipboard
Copied
The fields are not formatted to currency?
Wouldn't be easier to have a checkbox to switch between currency or even better two radio buttons?
Copy link to clipboard
Copied
Thanks. Check boxes or a dropdown would work as a placholder for now but ideally it would just take whatever currency sybol the user entered in the cell and copy it down to the autosum cell
Copy link to clipboard
Copied
There is a lot of info missing from your post, but I assume you manually enter the currency sign and that it's on the left of the value, also if the first field in the column would always be populated it would be enough to check only that field for sign.
Let's say that field name is "Text1", you would use something like this as custom format script of total field:
var text1 = this.getField("Text1").valueAsString;
var cur = text1.charAt(0);
event.value = util.printf(cur+" %,0.2f",event.value);
This is just a basic script, it can be updated to check if the first character is actually a currency sign...etc
Copy link to clipboard
Copied
Thanks. Yes you are correct the values are entered along with the currency symbol manually row by row. I will try your script and let you know how it goes.
Copy link to clipboard
Copied
Normally, the currency symbol is added automatically by the field's Format script. That way the user doesn't have to bother entering it each time, and it's much easier to sum fields up, for example.
I would recommend using a single drop-down field for currency selection. A custom-made script can then format the values entered by the user into the amount fields based on that selection.