- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 08:00 AM
Hi All,
Kindly provide solution for this.
I have two fields[Input Value is Numbers (a,b)] .On the third field[c] , I want the result of(a*b).
The problem I am facing is both [a,b] can be editable. If I write onchange Client script on A and if B value is edited. then c is populated with (a*b), where b is the old value but not the new value. Kindly help me in achieving this solution
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 08:49 AM
Hey Mate,
While you can write onChange on both fields, but again if B value is edited first then it will still take old Value of A. So till value of A is changed you still see the result of new Value of B X old value of A in field C. --> Why would this happen?? It will take the new value if you use that each time.
Had these scripts been querying server or something heavy I might have suggested doing this on submit/save only. But these are light weight calculations and important form a user perspective, so you want to see the result of change without having to save/submit the records.
Here is the scripts, client side, for A and B and working perfectly
-Anurag

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 08:28 AM
Hi Parnika,
Technically I don't think both values will be edited at the same time.
So when value A is edited how will the system know that B value is also going to be editable? Similarly if B is edited, how will system know that A is also going to be editable.
While you can write onChange on both fields, but again if B value is edited first then it will still take old Value of A. So till value of A is changed you still see the result of new Value of B X old value of A in field C.
The best solution is to write this in before insert/update BR
Filter conditions:
A changes OR
B changes
Script:
current.c=parseInt(current.a)*parseInt(current.b);
Mark the comment as correct/helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 08:49 AM
Hey Mate,
While you can write onChange on both fields, but again if B value is edited first then it will still take old Value of A. So till value of A is changed you still see the result of new Value of B X old value of A in field C. --> Why would this happen?? It will take the new value if you use that each time.
Had these scripts been querying server or something heavy I might have suggested doing this on submit/save only. But these are light weight calculations and important form a user perspective, so you want to see the result of change without having to save/submit the records.
Here is the scripts, client side, for A and B and working perfectly
-Anurag

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 09:33 AM
Hi,
If the value of B is edited first and then A, then in onChange of B, you get old value of A only. Thats what i meant in my above comment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 09:39 AM
I think that is expected, like any value can change , no specific order as such.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 09:44 AM
I think that's what was the problem reported. Hence suggested BR.