- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2020 11:38 AM
Hi,
I have a requirement where i have to append the dollar symbol on a decimal field. I cannot use a currency field due to certain restrictions.
The dollar should be ever present on the field, ie on load and even when the value is entered in the field, it should be saved with the dollar symbol.
Please suggest what can be done,
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2020 01:26 PM
This is what I did for a similar requirement.
First I created a field with the Type of String on the table, and put $ as the Default Value.
This makes it so that $ is displayed in the field when the New button is clicked to display the otherwise empty form.
Next I created a Business Rule on this table that runs Before Insert and Update with no Filter Conditions.
The script in the BR ensures that record is saved with the first character always a $, and it will also validate that the rest of the field contains a numeric value, forced to 2 decimal places if necessary. Note that in my requirement, Amount is not mandatory, so saving a record empty or with just the $ is valid. If you require an Amount, just remove the first if line (and corresponding closing bracket)
(function executeRule(current, previous /*null when async*/) {
if(current.u_amount != '' && current.u_amount != '$'){
var amt = parseFloat(current.u_amount.replace('$', '')).toFixed(2);
if(amt == 'NaN'){
gs.addInfoMessage('Please enter a valid Amount');
current.setAbortAction(true);
}
else{
current.u_amount = '$' + amt;
}
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2020 12:17 PM
Hi Srivatsa,
Currency signs are not supported by Decimal or Integer fields and even no dictionary attribute is available to make it working. If you would have string field then you could have achieve this requirement.
Please mark this correct & helpful if it answered your question.
Thanks & Regards,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2020 12:22 PM
can you tell me what could be done if I used a string field ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2020 12:27 PM
You can set default value as $ so that i should display on form load of new Record. Also, in addition to default value you need to write before BR to prefix the field value with $ sign.
Let me know if you need help with writting Buinsess rule.
Please mark this correct & helpful if it answered your question.
Thanks & Regards,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2020 01:26 PM
This is what I did for a similar requirement.
First I created a field with the Type of String on the table, and put $ as the Default Value.
This makes it so that $ is displayed in the field when the New button is clicked to display the otherwise empty form.
Next I created a Business Rule on this table that runs Before Insert and Update with no Filter Conditions.
The script in the BR ensures that record is saved with the first character always a $, and it will also validate that the rest of the field contains a numeric value, forced to 2 decimal places if necessary. Note that in my requirement, Amount is not mandatory, so saving a record empty or with just the $ is valid. If you require an Amount, just remove the first if line (and corresponding closing bracket)
(function executeRule(current, previous /*null when async*/) {
if(current.u_amount != '' && current.u_amount != '$'){
var amt = parseFloat(current.u_amount.replace('$', '')).toFixed(2);
if(amt == 'NaN'){
gs.addInfoMessage('Please enter a valid Amount');
current.setAbortAction(true);
}
else{
current.u_amount = '$' + amt;
}
}
})(current, previous);