The program, when a new database is automatically created, sets all the currency fields to the currency used by the system.
It may happen that you need to have a currency that does not correspond with the standard one and to be able to change it you would have to change every single currency field present.
This example allows you to act directly on the field settings.
CAUTION. IN THE EVENT OF ERRORS, ITS POSSIBLE TO GENERATE MALFUNCTIONS AND BLOCKS OF THE PROGRAM. SO BE CAREFUL AND TRY FIRST ON A TEST DATABASE.
We will act directly on the so_fields table, which is the table that manages all the fields in the database.
The one shown above is the dictionary that reports the characteristics of a currency filed. Inside are shown. The first CU1 value shows the code called culturinfo. To this link you can find the complete list. The second code is that of the currency and you can find the complete list at this link.
By changing these values we can therefore change the currency of the field.
t = database.getsql("SELECT * FROM so_fields WHERE fieldtype=5") nrows = t.countrows() rows = t.getrows() for i = 1, nrows do parameters= rows[i].getvalue("param") parameters = string.gsub(parameters,"it--IT","en-US") parameters = string.gsub(parameters,"EUR","USD") database.setsql("UPDATE so_fields SET tid=" .. tostring(utility.tid()) .. ",param='" .. utility.convap(parameters) .. "' WHERE gguid='" .. rows[i].getvalue("gguid") .. "'") database.addsyncbox("so_fields",rows[i].getvalue("gguid")) output.print(parameters) end
As we can see from the example, first we recover from so_fileds table all the fields of type 5, i.e. the currency fileds. Then using the lua commands we replace the current values with the desired ones and save them within the database.
In this way we forced the updating of all fields.
Given the type of operation, close the program and reopen it to allow the loading of the new values.