Why the field is returning the previus value in an catalog client script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2023 07:27 AM
Hello! I have an Onsubmit catalog client script on portal, in the script there is an alert that is showing twice, so with this i understand that the client is running twice. In portal, when the user change the current value of the field and press on SAVE button, the alert in the first run is showing the current value but the second run is showing the previus value. Any idea why this is happening?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2023 07:30 AM - edited ‎11-13-2023 07:53 AM
Hi @Community Alums
It will be good if you can share the code you have written on the client script.
Check if there is any restriction on any value you are trying to set during the form submission.
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2023 07:52 AM
Hi @Shubham Singh ! Yes of course:
function onSubmit() {
var test1 = g_form.getValue('test1');
var test2= g_form.getValue('test2');
if (test1 != 'TE' && test != 'AP') {
var multiRowVariableSet = JSON.parse(g_form.getValue('details')); //multirow variable set
var grandTotal = g_form.getValue('u_total');
var totalCost = 0;
for (var i = 0; i < multiRowVariableSet.length; i++) {
totalCost += parseFloat(multiRowVariableSet[i].total_exp); //variable of multirow
}
g_form.setValue("u_total", totalCost); //grand total variable outside of multirow
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2023 07:58 AM
@Community Alums
There is a typo in your if statement condition. I can see a test variable that is undefined.
if (test1 != 'TE' && test != 'AP') {
----your code------
}
function onSubmit() {
var test1 = g_form.getValue('test1');
var test2= g_form.getValue('test2');
if (test1 != 'TE' && test != 'AP') {
var multiRowVariableSet = JSON.parse(g_form.getValue('details')); //multirow variable set
var grandTotal = g_form.getValue('u_total');
var totalCost = 0;
for (var i = 0; i < multiRowVariableSet.length; i++) {
totalCost += parseFloat(multiRowVariableSet[i].total_exp); //variable of multirow
}
g_form.setValue("u_total", totalCost); //grand total variable outside of multirow
}
}
Thanks!
Mark it as correct and helpful if it works 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2023 09:19 AM
I changed that and is not working 😞