Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Convert the String/Float output values into a Currency value

Manoj82
Kilo Expert

Hi,

I need to update a Balance field (of Type :currency) on a table via a Business rule based on the calculations between two tables

Script:

var amount = 0;
var i = new GlideRecord('TableA');
i.addEncodedQuery('u_sn_number',current.u_sn_number');
i.query();
while(i.next()){
amount = amount + parseFloat(i.getValue('total_amount'));
}
var po = new GlideRecord('TableB');
po.addQuery('sys_id',current.u_po_number);
po.query();
if(po.next()){
po.u_balance = parseFloat(po.total_cost) - parseFloat(amount);
gs.log("check balance:"+po.u_balance,"checkbalance");
po.update();
}

The log messages and the addinfo message provides me the accurate value on the output but somehow not updating the Balance (Currency )field.

I created another field of "Floating" type and the calculations are being updated on the field as expected. So instead of creating a new filed I would like to see if there is possibility to convert the output into a Currency value and save in existing "Balance" filed

Regards,
Manoj

2 REPLIES 2

abhijitkhewale
Mega Expert

Hi Manoj,

Based on your query I have found below old post which I think might be helpful to you and will solve your issue.

 

https://community.servicenow.com/community?id=community_blog&sys_id=583eaa6ddbd0dbc01dcaf3231f9619fa

 

Regards,

Abhijit K

Hi Abhijitkhewale,

Thank you for sharing the info. Looks like my field got corrupted coz when I created a different currency field and used the same script it is working as expected.

Not sure how it got corrupted though.

Regards,
Manoj