Need to multiply 2 fields on portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 10:08 PM
Hi Team,
we have two fields :
number of request (single line text) and capacity (single line text).
we need to multiply these and set in capacity only once.
trying the below code
please help me with the code.
var res = parseInt(g_form.getValue('number_of_requests')) * parseInt(newValue); alert(res); g_form.setValue('capacity', res); |
So when number of request given 40 and capacity given 3 when user take off the cursor it should multiply and set as 120.
the above code should not trigger again (whereas not in a loop)
Please help!
Thanks!
Sri

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 11:40 PM
Just to understand, the calculation works but you get alert multiple times is what you mean? If so, how many times you get the alert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 12:17 AM
Hi Jaspal,
Many Times.
please find the screenshot
its multiplying nth time.
basically it should execute once.
please help!
Thanks,
Sri

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 12:19 AM
These are not the alerts you have added to the script but more of error messages. Is the widget modified? also, please check all relevant client scripts that run on the load of the form or so.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 12:23 AM
Hi Jaspal,
There is a alert message poping up by multiplying the values.
If we keep on clicking ok, then getting the above error message.
Please help!
Thanks,
Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 10:49 PM - edited 11-12-2023 11:10 PM
Hi @Sri56 ,
You can use below script to check if the calculated value is different from the current value
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var numberOfRequests = parseInt(g_form.getValue('u_request'));
var capacity = parseInt(g_form.getValue('u_capicity'));
var res = numberOfRequests * capacity;
var currentCapacity = g_form.getValue('capacity');
// Check if the calculated value is different from the current value
if (res !== currentCapacity) {
g_form.setValue('capacity', res);
alert(res);
}
}
Please mark it solution proposed and helpful if its serves your purpose.
Thanks,
Anand