[SOLVED] How to access NumberDecimal value in cloud code

Hi sorry if this is a bit of a noob question. Im trying to access the “decimal” column in my afterSave “BscTransactions” cloud trigger.

how do I actually get the value? when i try to log the return i get the following:

in my afterSave trigger i am getting the decimal object like so:

const value = request.object.get("decimal");
logger.info("afterSave BscTransactions value " + JSON.stringify(value));

which logs out:

afterSave BscTransactions value {"__type":“NumberDecimal”,“value”:{"$numberDecimal":“0.01”}}

now my question is how do I actually get the value for the decimal which is “0.01”. i have tried accessing via value.value.$numberDecimal but that doesnt work.

any help please as there seems to be zero documentation on this from what I could find.

thanks

There should be another column that has a string corresponding to that decimal value

It should also be possible to extract that value somehow but I don’t know now, maybe it is a method for that decimal class

not sure if its the right way but i ended up doing the following:

let value = request.object.get("decimal");
value = JSON.parse(JSON.stringify(value));
const decimalValue = value.value["$numberDecimal"];
1 Like