If you want to use scripts that, for example, convert currency characters or written-out currency names into ISO codes, please activate this first in the Settings under Doc Script.
After that, go to the desired document type. Once here, select the Scripts option.
You will be taken to the Scripts Menu. Once here, click on +NEW.
From here you have the choice of a Label, the document type, when the script for the document type should be triggered and also a specific sub document type if necessary. After adding the script in the provided area, click on SAVE.
For example:
currency_map = {
"€": "EUR",
"EURO": "EUR",
"$": "USD",
"£": "GBP"
}
currency_value = get_field_value(fields_dict, "currency", None)
if currency_value:
currency_value = currency_value.upper()
if currency_value in currency_map:
currency_value = currency_map[currency_value]
set_field_value(fields_dict, "currency", currency_value)
In the next step, upload a document with one of the following criteria: “€”, “EURO”, “$” or “£”.
When the document is ready for validation, open this and click in the Currency validation field. You will be prompted to select the appropriate area on the image. Now do this with the € sign.
You will then immediately see that € is converted to EUR by the script.
The same is done by the script when you mark EURO on the invoice.