I'm trying to set a default value when adding a new row to an interactive grid. In the blog of John Snyders I found an example of how to accomplish that:
1. create a dynamic action for the Row Initialization event on the IG region
2. add a JS action
In my example I want to set the value of the Department column to "Research" :
var val,
model = this.data.model,
rec = this.data.record,
meta = model.getRecordMetadata(this.data.recordId);
if ( meta.inserted ) {
val = model.getValue(rec, "DEPTNO");
if ( val.v === val.d ) {
model.setValue(rec,"DEPTNO", {d:apex.item("C_DEPT").displayValueFor("20"), v:"20"});
}
}
This works perfectly fine, but when I add a row and then switch the Saved Report, I get a javascript error "Error in action for 'selection-add-row'. TypeError: Cannot read property 'getRecordId' of null "and the default value is not set anymore.
You can reproduce the error here :
https://apex.oracle.com/pls/apex/f?p=127327:30