mauroghiglia
Member
Hi,
just wrote this code in a X.js form:
It calculates a grand total for repeat group field and it works fine when it's run in a form but when I run it in a detail view (however, I think I'm in a detail view since I'm modifying a record and .form is undefined) I get this error on the console:
TypeError: Fabrik.blocks[formRef] is undefined
It seems 'details_4' is wrong, but what do I have to use?
Hope someone has an idea...
just wrote this code in a X.js form:
Code:
function setRepeatElementsTotals() {
var elementName = 'orders_7_repeat___line_quantity';
var totalElement = 'orders___product_totals';
var total = 0;
if (typeof(Fabrik.blocks.form_4) == 'undefined') {
console.log('Details!!!');
var formRef = 'details_4';
} else {
console.log('Form!!!');
var formRef = 'form_4';
}
var elements = Fabrik.blocks[formRef].formElements;
elements.each(function (element, key) {
if (key.contains(elementName)) {
total += element.get('value').toFloat();
}
});
elements.get(totalElement).update(total);
};
It calculates a grand total for repeat group field and it works fine when it's run in a form but when I run it in a detail view (however, I think I'm in a detail view since I'm modifying a record and .form is undefined) I get this error on the console:
TypeError: Fabrik.blocks[formRef] is undefined
It seems 'details_4' is wrong, but what do I have to use?
Hope someone has an idea...