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!

Interactive Grid Error: Insert not allowed for new record

Sofía Martínez PastorJul 29 2024 — edited Jul 29 2024

Hello everyone,

I'm encountering an issue while trying to add new rows to an Interactive Grid (IG) in Oracle APEX. I've implemented a custom button to add a new row with predefined values, but I keep running into the error:

I have an Interactive Grid on my APEX page where users should be able to add new rows via a custom toolbar button. The grid is connected to a database table, and it allows editing of certain columns.

I added a button to the toolbar with the following configuration:

function(config) {
   let $ = apex.jQuery,
       toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(),
       toolbarGroup = toolbarData.toolbarFind("actions3"); // Find the actions group
   // Add new delete button to the toolbar
   if (toolbarGroup) {       
       // Add new add row button to the toolbar
       toolbarGroup.controls.push({
           type: "BUTTON",
           id: "add-row",
           label: "Añadir Bolsa",
           icon: "fa fa-plus", // Plus icon
           iconBeforeLabel: true,
           disabled: false,
           action: "add-row-values" // Custom action identifier
       });      
   }
   // Define the new action
   config.initActions = function(actions) {
       // Add action for adding a row with specific values
       actions.add({
           name: "add-row-values",
           label: "Añadir Bolsa",
           action: function() {
               var ig$ = apex.region("BOLSA_IG").widget(),
                   view = ig$.interactiveGrid("getCurrentView"),
                   model = view.model;
                   let recordId = model.insertNewRecord();
                   model.setRecordValue(recordId, 'COLUMN1', $v('P17_COLUMN1'));
           }
       });
   };
   config.toolbarData = toolbarData;
   return config;
}

The error message indicates that insertion is not allowed for the new record. Importantly, this issue only occurs when trying to add the first row to an empty Interactive Grid. When the grid already contains at least one row, the button functions as expected, and new rows can be added without errors.

Are there specific configurations or steps I might be missing to ensure that insertNewRecord works as intended?

Thank you in advance for your help!

Best regards,

Comments
Post Details
Added on Jul 29 2024
1 comment
852 views