0
votes

I have two region one form and one interactive grid like a master detail(company and company contact person ) how i can make the interactive grid mandatory ,the user can't submit page ,he/she need add at least one row in interactive grid , I can do that or I need to change the interactive grid to collection and count the row in validation

1
You said the user can't submit the page. Why not? Perhaps the easiest thing to do would be to validate the value on submit? I'll provide an answer that takes this approach.Dan McGhan

1 Answers

2
votes

This one is a little tricky because of the way processes and validations work with Interactive Grids (they are executed once per submitted row). To work around this, I'll use a page item and a validation that works with it.

The basic idea of this solution is based on the fact that a new row will not have a primary key value. Here are the steps to reproduce (my example was on page 14, update the following as needed).

  1. Create an Interactive Grid (IG) region. The primary key column should be Query Only (which ensures it's null for new rows).
  2. Create a Hidden page item named P14_NULL_FOUND. Set Type under Server-side Condition to Never so that it never renders on the page.
  3. Create an After Submit (before Validations) process. This process will NOT be associated with the IG so it will only fire once. Set the PL/SQL Code attribute to:

    :P14_NULL_FOUND := 'NO';
    

    That will clear out the value of the page item prior to the next process.

  4. Create another After Submit process that runs just after the previous one. Set Editable Region to the IG. Then set the PL/SQL Code to something like the following:

    if :PK_COLUMN_IN_IG is null
    then
      :P14_NULL_FOUND := 'YES';
    end if;
    

    You'll need to replace ":PK_COLUMN_IN_IG" with the name of the primary key column in the IG, such as ":EMPNO". This process will be run once for each submitted row in the IG. If a null value is found for the primary key column, then that would mean the user added a new row and the value of P14_NULL_FOUND would be set to 'YES'.

  5. Create a new validation. This validation will NOT be associated with the IG so it will only fire once. Set Type to PL/SQL Expression. Set PL/SQL Expression to:

    :P14_NULL_FOUND != 'NO'
    

    Then set Error Message to something relevant.

At this point, you should be able to run the page and verify that the processes and validation are working correctly.