- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 05:29 AM
HI Community,
I have a requirement, in catalog form we have these variables, based on the amount selected the approver need to be populated in the additional approver field. I have written a script but it is not working as expected it because the value in amount in eur will display as 400 000.00 and not as 400000.00 (we have used regex pattern in script to achieve this) because of this my existing script is not populating the approver details.
catalog client script:
How can we achieve this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 05:37 AM
Hi @suuriyas
Add the below lines to your script. It'll work as expected.
var amt = g_form.getValue("amount_in_eur");
//-----START------
var result = amt.replace(/\s+/g, "");
//-----END--------
var ru = g_form.getValue("reporting_unit");
var ajax = new GlideAjax('x_kaoy_finops.PaymentApproverFilter');
ajax.addParam('sysparm_name', 'vendorapproverFilter');
ajax.addParam('sysparm_reporting_unit', ru);
ajax.addParam('sysparm_amount', result); // send the converted string
ajax.getXML(getApprover);
function getApprover(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
// alert(answer);
g_form.setValue('approver', answer);
}
Hope this helps.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 05:37 AM
Hi @suuriyas
Add the below lines to your script. It'll work as expected.
var amt = g_form.getValue("amount_in_eur");
//-----START------
var result = amt.replace(/\s+/g, "");
//-----END--------
var ru = g_form.getValue("reporting_unit");
var ajax = new GlideAjax('x_kaoy_finops.PaymentApproverFilter');
ajax.addParam('sysparm_name', 'vendorapproverFilter');
ajax.addParam('sysparm_reporting_unit', ru);
ajax.addParam('sysparm_amount', result); // send the converted string
ajax.getXML(getApprover);
function getApprover(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
// alert(answer);
g_form.setValue('approver', answer);
}
Hope this helps.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 05:55 AM
HI @J Siva ,
It worked
But can you please explain me what this command is, it would be helpful for me to understand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 07:07 AM - edited 03-28-2025 07:31 AM
Sure. It'll remove the white spaces from the string.
\s -> white space
We are removing all the white spaces by replacing it with empty string.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2025 05:51 AM
@suuriyas - I can see the variable is of type currency. Can you share the field type (min_amount_in_approval_eur & max_amount_in_approval_eur)on the table against which you are running the amount comparison.
Thanks & Regards,
Vasanth