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.
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
how to use this JS code?
ReplyDeleteThanks
Copy and paste it into your Function and Global Variable Declaration section of the page
Deleteit's working. thanks.
Deletei want auto serial no in a IG column for save. not Sequence Row Header. is it possible.
Yes it is possible, check how we are getting Salary and Empno on JS lines 11 and 12
Deletei would like to check duplicate in a single column.. is it possible to check ?
DeleteYes it is.
DeleteCan you please explain what is salary in line 28
ReplyDeleteAlso hitting with the below error, how to fix
Error: Line 28:['salary'] is better written in dot notation.
Please ignore my previous post.
ReplyDeleteI was able to resolve the same
not working in apex 5.1
ReplyDeleteIt works fine in apex 19.1, thank you very much. I'll see the way to solve that problem in apex 5.1
ReplyDeleteWill it work with filters
ReplyDeleteI tried disabling the filters before the model is fetched but as disabling filter is asynchronous it dint help
DeleteI 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.
Deletehey 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?
ReplyDeletePlease make sure you copy the code into Function and Global Variable Declaration and that you give your IG region a static ID emp
DeleteWhere should I call this function? SHould I create a DA on the Emp Name and call update(model)?
ReplyDeletePlease make sure you copy the code into Function and Global Variable Declaration and that you give your IG region a static ID emp
Deleteits looking good but i don't know where to write this code and how to call it. any one can please guide me.
ReplyDeleteCopy and paste it into your Function and Global Variable Declaration section of the page
DeleteHello,
ReplyDeletei tried to check duplicate records on ENAME columns but no luck.
could you please let me know how to check duplicate ENAME in the same JS.
Thanks
It should be easy.... similar to before https://apex.oracle.com/pls/apex/f?p=84111:22 does the ename checks. This is the JS used here https://jsfiddle.net/xn50cr6a/
DeleteHi, Even we have the requirement to check duplicate for the Varchar ( Ename ) example, is there a chance to share that JS code
Deletehttps://jsfiddle.net/xn50cr6a/
DeleteHi, Even we have the requirement to check duplicate for the Varchar ( Ename and Sal ) if two or more then cloumn value same then duplicate message
Deletevar duplicateIds = recArray
Delete.map(e => e['empname'])
.map((e, i, final) => final.indexOf(e) !== i && i)
.filter(obj => recArray[obj])
.map(e => recArray[e]["empname"]);
this code if (empname And Sal ) Same Value Then duplicateIds >0 How can i Do this
Thanks Sir.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi I have two column i.e STORY_WORK_ORDER_ID(primary_key) and WORK_ORDER_ID and i want to validate that user cannot add two same work_order
ReplyDeletethankyou i found the issue work now perfect solution.
Delete