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,
Lino

8 comments:

  1. how to use this JS code?
    Thanks

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

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

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

      Delete
  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.

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

    ReplyDelete
  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

    ReplyDelete