Stop duplicate records from being created
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2012 08:50 AM
Hi everyone, I have a UI action that is on the task table and when clicked creates a record on a user created table (u_m2m_time_card). When a record is created is it bringing over the task number and who created the record. The problem I am having is with duplicate entires. Users can hit this UI action multiple times and a new record will be inserted each time. I want to limit that and only one record with the same task number and same user can be created. The same task number can be there, just as long as there isnt one with the same user ID already there. I am struggling to make that happen. Should I do this in the current UI action code? or should I make a new business rule? Here is the code behind the UI action
var ID = current.sys_id.toString(); var User = gs.getUserID(); var card = new GlideRecord('u_m2m_time_card'); card.initialize(); card.u_task = ID; card.u_user = User; card.insert(); gs.addInfoMessage("This task has been added to your queue."); action.setRedirectURL(current);
I tried a couple approaches without any success. Any help? Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2012 09:44 PM
Hi Guys,
In my case,even if I checked duplicate before insertion of record in M2M, If two users are trying to add the same record at the same time I am facing issue of duplicate records.