Has anyone done a calculation in quickcreate? (SuiteCRM 7)
I regularly do calculations in editview by loading a custom JS file in editviewdefs like this:
(Price times quantity)
// Custom JavaScript code
$(document).ready(function() {
console.log('Custom script for updateTotalWorkorder loaded successfully2.');
// Function to update total_billing based on price and quantity
function updateTotalWorkorder() {
var price = parseFloat($('#price').val()); // Ensure you're using the correct ID
var quantity = parseFloat($('#quantity').val()); // Ensure you're using the correct ID
if (!isNaN(price) && !isNaN(quantity)) {
var totalWorkOrder = price * quantity;
$('#total_workorder').val(totalWorkOrder.toFixed(2)); // Use .val() for input fields
} else {
$('#total_workorder').val(''); // Clear the field if price or quantity are not valid numbers
}
}
// Attach event listeners to price and quantity fields
$('#price, #quantity').on('input', updateTotalWorkorder);
// Initialize total_workorder field
updateTotalWorkorder();
});
And it works great in editiview. I’ve tried the same thing in quickcreate and I just can’t get it to work.
Firstly, it seems to load twice. (and it’s not loading from both editview and quickcreate, I’ve ruled that out).
And I can’t get it to work. Has anyone else done something similar in quickcreate to calculate a field live on the screen? ( I know I can do this on save with workflow and also with a logic hook).