Currency in Record Producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2014 12:10 PM
Hi All,
To my surprise, I don't see any 'currency' (or equivalent) data type in the record producer's variable. So, I created two fields - one for the currency ("Old Currency" variable - datatype: Select Box; with dropdown values of world currencies) and one for the current value ("Old Price" variable - datatype: Single Line Text; with a client script that evaluates 2-decimal places numeric values).
In the target table, I have a field which can hold a currency ("Old Price" field - datatype: Currency).
Question: How do I map "Old Currency" variable and "Old Price" variable into "Old Price" field?
In the record producer, there is a "Script" field and I may do server-side scripting. I can use "current" to set values for the target table and I can use "producer" object to retrieve the "Old Currency" variable's value. I tried using a Glide Record to force the currency but no luck.
===========================================================
Here's my script so far:
var myOldCurrt = producer.oldCurrency.toString();
gs.log(current.sys_id,'MCS 1');
var old = new GlideRecord('fx_currency_instance');
old.addQuery('id', current.sys_id.toString());
old.addQuery('field', 'u_old_price');
old.query();
gs.log(old.getRowCount(),'MCS 2');
if(old.next()) {
old.currency = myOldCurrt;
old.update();
}
//var myNewCurrt = producer.newCurrency.toString();
===========================================================
I appreciate it for any tips or leads.
Thanks,
Dor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2014 05:22 PM
Right, you can use current and producer to get your results:
current.old_price = producer.old_price;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2014 10:24 AM
The amount is transferred but not the currency.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2014 12:43 PM
Hey Dor,
I'm not sure if you've got this figured out yet but the wiki has some good information on scripting currency fields linked below. The issue is that a currency field assumes the currency of the current users session unless specified in the format (<currency field> = "USD;<amount>"). So, in you're case you'd need to do something like the below:
// field_name = "<currency>;<amount>";
// Example to set with USD
current.old_price = "USD;" + producer.old_price;
// The interpreted output should be
current.old_price = "USD;200.99";
Scripting Currency and Price Fields
I hope that helps,
Jared Healy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2014 02:07 PM
This is the right answer!!!!! Thank you........