Hello.
I'm new in this forum and with Memento.
I'm not a javascript expert, but I want to create a test Library that can get from an internet link a currency exchange and then calculate the total price in that currency for a given quantity.
For that, I created the fields Date, Quantidade, Total (script), Nome and Preco.
And then, I created an autofill (trigger ?) script, like the one at the end and shared with the title CurrencyCalc, under dtsbsb account (escuse-me the comments tests).
With this, I can get the correct currency exchange for a date, but my script can't set the field Preco in the Library to calc the Total (Preco * Quantidade).
I think that it's a context error.
Is there any library like this that I can study ?
Thanks in advance.
dtsbsb
Autofill script:
________________________________________________________________________________
var http = http();
lib = lib();
message("Library " + lib.title );
e = entry();
var result = http.get("http:\/\/
economia.awesomeapi.com.br/json/last/USD-BRL");
var headerValue = result.header("etag"); //Get response header
//message(result.header("origin"));
message (result.body);
message(result.code + " - código de retorno http");
usdToEur = JSON.parse(result.body) ["USDBRL"]
["bid"];
message("cotação do Dólar em Real = " + usdToEur);
//Preco = usdToEur;
//e.set ( "Preco", usdToEur );
//entry[1].set("Preco") = usdToEur;
message("field Preco = " + e.field("Preco"));
//result(usdToEur);
//entry().set("Nome", name );
//entry().field("Total") = entry().field("Preco") * usdToEur);
//message("Total = " + entry().field("Total"));