Introduction:

To avoid duplicate values in Interactive Grid in Oracle APEX.

Cause of the issue:

In newly created APEX Page, there is user requirement to validate the duplicate values on entering or changing the description.

How do we solve:

The below is the script to validate the Duplication on entering or modifying the existing content.

Steps:

  • Create a new dynamic Action
  • Event – Change
  • Selection type – Columns
  • Region – Interactive Grid Region
  • Column – Plan_Description

On True Action, set Action as “Execute Javascript Code” and place the below code in it.

Script:

var $te = $(this.triggeringElement);

var cur_rowId = $te.closest(‘tr’).data(‘id’);

var cur_item_num = apex.item( “PLAN_DESCRIPTION” ).getValue().toUpperCase();

var widget = apex.region(‘PLAN_ITEM_IG’).widget();

var grid = widget.interactiveGrid(‘getViews’, ‘grid’);

var model = grid.model;

apex.message.clearErrors();

model.forEach(function(record) {

if (cur_rowId != model.getValue(record, ‘PLAN_ID’)) {

if (cur_item_num == model.getValue(record, ‘PLAN_DESCRIPTION’).toUpperCase()) {

apex.item( “PLAN_DESCRIPTION” ).setValue( “” );

apex.message.showErrors([{

type: “error”,

location: “page”,

message: Item Description already exists. Please adjust the description or use this Item Number -‘+model.getValue(record, ‘PLAN_NUMBER’),

unsafe: false

}]);

}}})

Recent Posts

Start typing and press Enter to search