We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

how to remove decimal from the string field in the server side script

RudhraKAM
Tera Guru

I have this code in the server side , it is giving the result as 44.0 I want only 44 

 current.variables.sds_price = parseInt(current.cmdb_ci.market_value)/1024;

1 ACCEPTED SOLUTION

hvrdhn88
Giga Patron

Please check sample examples from below link , give a try . let me know if it's still not working. 

 

https://stackoverflow.com/questions/7641818/how-can-i-remove-the-decimal-part-from-javascript-number

View solution in original post

12 REPLIES 12

Hi there,

 

Could you please let us know the 'type' of the 'market_value' column on the 'cmdb_ci' table?

  1. In the App Nav type 'cmdb_ci.config'
  2. In the 'Dictionary Entries' tab, search for the Column name 'market_value'
  3. What 'type' is that column?

RudhraKAM
Tera Guru

Thanks Every one , I Fixed this by setting 

 

num = num.toFixed(0);

Nice. Just be aware that number will be a string!