Set page item value from grid on click

I’m trying to set a page field with a value from the Interactive Grid (IG) column on the row I’m currently on. I want the value to change if I change the row I’m on.

I’ve assigned a static ID (IG_GRID) to the IG and one of the columns is named OS_TIP. The page item I want to update is P660_LOV_OS_TIP.

I’ve created a Dynamic Action on the IG Region with the event “Selection change [Interactive grid]”. For the “True” Action, I’ve set the type as “Set Value” and used the following Javascript expression:

apex.region("IG_GRID").widget().interactiveGrid("getViews").grid.model.getValue($v("CURRENT_ROW_INDEX"), "OS_TIP")

The Affected Items selection type is “Item’s” and the item selected is P660_LOV_OS_TIP. However, when I click anywhere on the grid, nothing happens and my page item is not set with a value. When I enter the JS code in the console, I get an “undefined” response.

What am I doing wrong? How can I set this page item by selecting an IG row?

The issue may be with the JavaScript expression you are using in your Dynamic Action. Instead of using $v("CURRENT_ROW_INDEX"), you should use this.triggeringElement to get the current row index.

Here is the corrected JavaScript expression:

apex.region("IG_GRID").widget().interactiveGrid("getViews").grid.model.getValue(this.triggeringElement, "OS_TIP")

Try updating your Dynamic Action with this expression and see if it resolves the issue.