Saturday, 4 April 2020

Interactive grid validation duplicated rows check

APEX and IG validation part 2


Interactive grid validation

Check for duplicates using JavaScript

In my first blog I tried to address the problem of checking for duplicated rows in IG but as you have seen it did not cover for most obvious problem which is immediate validation of your data on the client.

If you would to enter two of the same values at one go validation would still submit both to DB which is not what we want. 

Just recently I have seen post by Tobias Arnhold and AskMax on a same subject so......

it only means there is more people challenged with the same problem. 
It was on my to do list for a long time and now that everything slowed down I finally found time to see what we can do about it. This example raised so many questions on my previous post so hoping this will help solve some of these too.
With snippet of JS added to your page with standard IG based on EMP table with static ID set to 'emp':

Pretty much all of the code is taken from John Snyder's IG cookbook examples and I added a section to check for duplicates. 
Download the full JS.  

That should be all. 
Leaving you with live demo @here.

Happy APEXing,


  1. how to use this JS code?

    1. Copy and paste it into your Function and Global Variable Declaration section of the page

    2. it's working. thanks.
      i want auto serial no in a IG column for save. not Sequence Row Header. is it possible.

    3. Yes it is possible, check how we are getting Salary and Empno on JS lines 11 and 12

  2. Can you please explain what is salary in line 28
    Also hitting with the below error, how to fix
    Error: Line 28:['salary'] is better written in dot notation.

  3. Please ignore my previous post.
    I was able to resolve the same

  4. It works fine in apex 19.1, thank you very much. I'll see the way to solve that problem in apex 5.1

  5. Will it work with filters

    1. I tried disabling the filters before the model is fetched but as disabling filter is asynchronous it dint help

    2. I didn't try this with filters yet. It may have to do with a 'filtered' view and data collected by IG where it seems my current solution looks at whole loaded model.

  6. hey so i added this in Function and Global Variable Declaration but its not working....added a table with columns id, emp, sal ...any idea why?