- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 09:48 PM
Create a button (Total amount) whenever we click that button that button should calculate(quantity*price)
please suggest me possible ways how to achieve this.
Solved! Go to Solution.
- Labels:
-
Cre

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 12:10 AM - edited 04-25-2024 12:11 AM
Hi @siva118 ,
I tried your problem in my PDI and it works for me, Please check the script below
function showTotal(){
alert("here");
var quan = g_form.getValue('u_quantity');
var price = g_form.getValue('u_price');
var total = g_form.getValue('u_total');
alert("quan = " + quan + " price = " + price + " total = " + total );
g_form.setValue('u_total', quan*price);
}
Note: I create 3 fields on incident table - Quantity - Integer type, Price- Integer type, Total - Integer type
Result
When I click total button it shows the result
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 03:21 AM
Hi @siva118 ,
I had done as you say like quantity field type is (Integer), Price field type is (currency), Total Amount field is (currency)
function showTotal() {
var quan = g_form.getValue('u_quantity');
var price = g_form.getValue('u_price_222');
var total = g_form.getValue('u_total_222');
alert("quan = " + quan + " price = " + price + " total = " + total);
var intPrice = price.split(';');
alert('intPrice = ' + intPrice[1]);
var intTotal = total.split(';');
var totalValue = intTotal[0] + ";" + quan * intPrice[1];
alert('Total = ' + intTotal);
g_form.setValue('u_total_222', totalValue);
}
Here is result
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 10:08 PM
Hi @siva118
Navigate to System UI -> UI Actions.
Apply on form header
function calculateTotal() {
// Get the current record
var currentRecord = g_form.getUniqueValue();
// Assuming 'quantity' and 'price' are the field names
var quantity = parseFloat(g_form.getValue('quantity'));
var price = parseFloat(g_form.getValue('price'));
// Calculate total
var total = quantity * price;
// Set the total amount field
g_form.setValue('total_amount', total.toFixed(2)); // Adjust field name accordingly
}
if (typeof window == 'undefined') {
calculateTotal();
}
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 10:42 PM
I have try this but it's not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 11:24 PM
Hi @siva118
try to remove if condition The check if (typeof window == 'undefined')

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 12:10 AM - edited 04-25-2024 12:11 AM
Hi @siva118 ,
I tried your problem in my PDI and it works for me, Please check the script below
function showTotal(){
alert("here");
var quan = g_form.getValue('u_quantity');
var price = g_form.getValue('u_price');
var total = g_form.getValue('u_total');
alert("quan = " + quan + " price = " + price + " total = " + total );
g_form.setValue('u_total', quan*price);
}
Note: I create 3 fields on incident table - Quantity - Integer type, Price- Integer type, Total - Integer type
Result
When I click total button it shows the result
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak