- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-26-2023 10:06 PM
Hi all, so i have 4 fields in form like,
Unit price - 5000
Quantity - 6
discount - 10%
when i fill this fields
Total price field should be filled automatically...How to achieve this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2023 10:49 PM
@SAM321 you should right click on unit in your form and see the field name and that names of other fields respectively should be changed in the script in order to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-26-2023 10:19 PM
Hi, exactly how depends on if this value needs to be visible to the end user before the form is saved? If yes then you would want a client script for each of the 3 contributing fields that recalculates the total when the field is changed.
If the total does not need to be set on the form, then you can use a before insert\update BR triggering when one of the 3 fields changes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-26-2023 10:29 PM
Hi @SAM321
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var Up = g_form.getValue('u_unitprice');
var units = g_form.getValue('u_units');
var dis = g_form.getValue('u_discount') / 100;
var tot = Up * units * dis;
g_form.setValue('u_total',tot);
//Type appropriate comment here, and begin script below
}
try this piece of code and please mark my answer as helpful if it helps you in any way.
Regards,
Aditya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-26-2023 11:23 PM
@Tony Chatfield1 yes, i need script for , whenever any of the above field get changes , The total Field should get value automatically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2023 02:09 AM
Hi @SAM321 , try the script by changing the getvalue parameters with your field's name for the same and it should work.
Do mark my ans helpful.
Regards,
Aditya