Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problems setting default value when adding new row to interactive grid

steffi_mMar 23 2018 — edited Mar 23 2018

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

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 20 2018
Added on Mar 23 2018
4 comments
4,607 views