- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2020 04:38 PM
I need to compare a currency value field on a client side script. If the currency field value is less than 10,000 than an info message appears. How do I access the integer value of the currency field? The server side equivalent is "getCurrencyValue", I don't what to do client side though. Also, "onChange script error: ReferenceError: u_final_offer is not defined function () { [native code] }" is an errorI'm getting when executing my client script.
Please help.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2020 06:06 PM
I would suggest you to write UI policy on curreny field rather than writing client script directly.
Condition : currency is between 0 and 10000
Then go to the script tab select "Run Scripts" and the code below
g_form.showFieldMsg('currency','Your message here','error');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2020 04:56 PM
1st lets do alert and see what value you are getting like
alert(g_form.getValue(u_final_offer));
if you are getting like 1000 than you can compare it like
if(g_form.getValue(u_final_offer) <= '10000'){
//do something
}
if you are getting something like USD;0.00 than you can do something like
if(g_form.getValue(u_final_offer) <= 'USD;10,000.00'){
//do something
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2020 05:11 PM
As far as I know we don't have client side function to get currency value. Try this to extract integer value from currency field.
var finalOffer = g_form.getValue('u_final_offer');
var finalOfferStr = finalOffer.split(';')[1];
var finalOfferInt = parseInt(finalOfferStr);
if(finalOfferInt >= 10000) {
//logic here
}
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2020 08:46 AM
This script is cutting out only the first comma from the currency value. So for example if I type 31,000,000 the output is 31.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2020 11:44 AM
The Script is basically splitting the value based on semi-colon. it strange that its cutting the value based off comma. Did you checked what exact value are you getting from u_final_offer field?
Muhammad