- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 12:27 AM
I have a variable named amount in my record producer. After adding the value to the variable i want to add a $ symbol infront of the value.
EG : If I enter 2000 , I want $2000.
I tried onChange client script but it is not worked as expected.
Please help
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 12:33 AM
Does this help?
function FormatPrice(varName, strValue) {
//varName is the variable name
//strValue is the entered value of the Single Line Text variable
var xNum = Number(strValue.replace(/[^0-9.]/g, "")).toFixed(2);
var xStr = xNum.toString();
xStr = '$' + xStr.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
g_form.setValue(varName, xStr);
return;
}
This function is then called on the OnChange catalog client script for the cost variable
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
FormatPrice('cost', newValue);
return;
}
If my answer helped you in any way, please then mark it as helpful.
Mark
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 12:45 AM
Hi,
What type of field is that amount?
Can you also share the script you already tried
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 02:48 AM
It is string filed.
This is my code.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var amount = g_form.getValue('amount');
g_form.clearValue('amount');
g_form.setValue('amount','$'+amount);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 04:32 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
try
{
var str = '$'+newValue;
g_form.setValue('your_cost_field',str);
}
catch(e)
{}
}