I have a ListGrid with a series of Integer fields followed by two fields of ListGridFieldType.SUMMARY. The first of the two summary fields (perStore) is a simple SUM of the series of Integer fields using the built-in RecordSummaryFunctionType.SUM and works fine.
The second summary field "extendedTotal" needs to be calculated by multiplying the "perStore" total by another IntegerItem "numberOfStores" on a form in the same Canvas as the ListGrid. I've tried coding the following but am getting a null pointer error on the record.getAttributeAsInt("perStore") line. How can I access the auto-calculated summary field "perStore" and be sure that it has already been calculated by the time the "extendedTotal" summary function executes.
The second summary field "extendedTotal" needs to be calculated by multiplying the "perStore" total by another IntegerItem "numberOfStores" on a form in the same Canvas as the ListGrid. I've tried coding the following but am getting a null pointer error on the record.getAttributeAsInt("perStore") line. How can I access the auto-calculated summary field "perStore" and be sure that it has already been calculated by the time the "extendedTotal" summary function executes.
Code:
extendedTotal.setRecordSummaryFunction(new RecordSummaryFunction() { @Override public Object getSummaryValue(Record record, ListGridField[] fields, ListGridField summaryField) { // Multiply row perStore total by number of stores Object numberOfStoresInt = form.getItem("numberOfStores").getValue(); if (numberOfStoresInt==null) return null; return record.getAttributeAsInt("perStore") * (Integer)numberOfStoresInt; } });
Comment