Casting Field Values using TO_NUMBER and TO_NCHAR

Fields in NetSuite store values in different data types, such as STRING, INTEGER, and FLOAT.

  • String- text values, such as a customer name
  • Integer- positive or negative whole numbers that do not contain a decimal, such as counts
  • Float- numeric values that can contain a decimal, such as amounts

Some fields need to be cast to a different data type before you can use them in a custom formula field, or before you can perform arithmetic operations with them. For example, if item price was stored as an INTEGER value and item cost was stored as a FLOAT value, you could use the following formula definition to calculate the difference between the two:

TO_NUMBER({item<pricing.unitprice}) - TO_NUMBER({cost}) 

Leave a comment

Your email address will not be published. Required fields are marked *