- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Good morning everyone,
i've been creating finance request forms for my firm's finance department and have a request that i am not sure how to proceed in developing.
Currently, when someone purchases an item in another currency we want to see the currency they used. the price in that currency and then the amount converted to CAD.
Which they will be paid out in CAD
The user would then first put in the amount converted which in this case is 125.25
By default the currnecy used is CAD but if they purchase in another they will choose and then the thrid field will show the USD> 100.01 which they put in themselves
My question, is there a simpler way to do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
35m ago
Hi Peter,
The current process feels "backwards" for the end-user because it asks for the result (CAD) before the input (Original Amount).
The "Simpler Way" (Better UX): Flip the logic. Ask the user for the Original Amount and Currency first, then let ServiceNow automatically calculate the estimated CAD amount for them.
Note: Since credit card exchange rates differ from system rates (due to bank fees), you should always leave the final "CAD Amount" field editable so the user can match it exactly to their bank statement.
Here is the setup to automate this:
1. Create/Arrange your Variables
original_currency (Select Box/Lookup Select Box pointing to fx_currency or just static choices like USD, EUR).
original_amount (Decimal or Single Line Text).
reimbursement_amount_cad (Decimal) -> This will be auto-populated.
2. The Backend Logic (Script Include) Create a Client Callable Script Include to fetch the system exchange rate.
Name: CatalogCurrencyHelper
Client Callable: Checked
var CatalogCurrencyHelper = Class.create(); CatalogCurrencyHelper.prototype = Object.extendsObject(AbstractAjaxProcessor, { convertCurrency: function() { var amount = this.getParameter('sysparm_amount'); var fromCurr = this.getParameter('sysparm_currency'); var toCurr = 'CAD'; // Target currency if (!amount || !fromCurr) return ''; // Use the native Currency Converter API var converter = new sn_currency.GlideCurrencyConverter(fromCurr, toCurr); converter.setAmount(amount); var result = converter.convert(); return result.getAmount(); // Returns the converted value }, type: 'CatalogCurrencyHelper' });
3. The Frontend Logic (Catalog Client Script) Create an onChange script that triggers when the Currency or Original Amount changes.
Type: onChange
Variable: original_amount (Create a similar one for original_currency)
function onChange(control, oldValue, newValue, isLoading) { if (isLoading || newValue == '') { return; } var currency = g_form.getValue('original_currency'); // e.g., 'USD' if (!currency || currency == 'CAD') return; var ga = new GlideAjax('CatalogCurrencyHelper'); ga.addParam('sysparm_name', 'convertCurrency'); ga.addParam('sysparm_amount', newValue); ga.addParam('sysparm_currency', currency); ga.getXMLAnswer(function(response) { if (response) { // Set the estimated CAD amount // You might want to round it: parseFloat(response).toFixed(2) g_form.setValue('reimbursement_amount_cad', response); g_form.showFieldMsg('reimbursement_amount_cad', 'Estimated based on today\'s rate. Please adjust to match your bank statement if needed.', 'info'); } }); }
Result: The user types 100 and selects USD. The system instantly populates 135.50 in the CAD box. The user smiles because they didn't have to do the math.
If this response helps you, please mark it as Accepted Solution.
This helps the community grow and assists others in finding valid answers faster.
Best regards,
Brandão.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi,
you can take the help from this video
I have used the similar steps in my scenario.
Thanks,
Gargi
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
38m ago
thank you i have already saw this video but its not the same as what i am trying to do.
This is for an MRV where users have expenses they are submitting for Reimbursement but they purchase various items in different currencys
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
35m ago
Hi Peter,
The current process feels "backwards" for the end-user because it asks for the result (CAD) before the input (Original Amount).
The "Simpler Way" (Better UX): Flip the logic. Ask the user for the Original Amount and Currency first, then let ServiceNow automatically calculate the estimated CAD amount for them.
Note: Since credit card exchange rates differ from system rates (due to bank fees), you should always leave the final "CAD Amount" field editable so the user can match it exactly to their bank statement.
Here is the setup to automate this:
1. Create/Arrange your Variables
original_currency (Select Box/Lookup Select Box pointing to fx_currency or just static choices like USD, EUR).
original_amount (Decimal or Single Line Text).
reimbursement_amount_cad (Decimal) -> This will be auto-populated.
2. The Backend Logic (Script Include) Create a Client Callable Script Include to fetch the system exchange rate.
Name: CatalogCurrencyHelper
Client Callable: Checked
var CatalogCurrencyHelper = Class.create(); CatalogCurrencyHelper.prototype = Object.extendsObject(AbstractAjaxProcessor, { convertCurrency: function() { var amount = this.getParameter('sysparm_amount'); var fromCurr = this.getParameter('sysparm_currency'); var toCurr = 'CAD'; // Target currency if (!amount || !fromCurr) return ''; // Use the native Currency Converter API var converter = new sn_currency.GlideCurrencyConverter(fromCurr, toCurr); converter.setAmount(amount); var result = converter.convert(); return result.getAmount(); // Returns the converted value }, type: 'CatalogCurrencyHelper' });
3. The Frontend Logic (Catalog Client Script) Create an onChange script that triggers when the Currency or Original Amount changes.
Type: onChange
Variable: original_amount (Create a similar one for original_currency)
function onChange(control, oldValue, newValue, isLoading) { if (isLoading || newValue == '') { return; } var currency = g_form.getValue('original_currency'); // e.g., 'USD' if (!currency || currency == 'CAD') return; var ga = new GlideAjax('CatalogCurrencyHelper'); ga.addParam('sysparm_name', 'convertCurrency'); ga.addParam('sysparm_amount', newValue); ga.addParam('sysparm_currency', currency); ga.getXMLAnswer(function(response) { if (response) { // Set the estimated CAD amount // You might want to round it: parseFloat(response).toFixed(2) g_form.setValue('reimbursement_amount_cad', response); g_form.showFieldMsg('reimbursement_amount_cad', 'Estimated based on today\'s rate. Please adjust to match your bank statement if needed.', 'info'); } }); }
Result: The user types 100 and selects USD. The system instantly populates 135.50 in the CAD box. The user smiles because they didn't have to do the math.
If this response helps you, please mark it as Accepted Solution.
This helps the community grow and assists others in finding valid answers faster.
Best regards,
Brandão.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
13m ago
Wow this is amazing i have implemented this and works beautifully.
i dont know what i can say but thank you very much for this
