Apex: Defaulting a value in an interactive grid

 Requirement

You want to default a value in an interactive grid, for example to enforce a master/detail relationship
 
In the below screenshot I'm defaulting a vlue of "20".


Solution

You need JS to get a client-side value, you can't use SQL to set a default.

Create a DA on your grid.


It needs to fire this JS.

var model = this.data.model,    rec = this.data.record,    meta = model.getRecordMetadata(this.data.recordId);if ( meta.inserted ) {    model.setValue(rec,"PROJECT_ID", $v("P22_ID"));}
 
Note: If your item is display-only or hidden, this won't work, it needs to be a text item.
I worked around this by hiding the column in my IG report.
 

Acknowledgement:

https://community.oracle.com/tech/developers/discussion/4319240/interactive-grid-default-value 

Comments