Prevent creation of duplicate records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 05:30 AM
Hello Team,
I have created one business rule to create records on a new table based on insert/update on the existing table. The current issue is duplicate records are being created, everytime an insert or update action performed on the existing table. Only one entry of the records are required on the new table.
I want the validation code on the same business rule which is used to create the new records to prevent creation of duplicate records.
It is a before type business rule running on insert/update.Below is the business rule:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 05:47 AM - edited 08-19-2024 05:48 AM
You need to first validate if the record already exists or not.
(I copied your code after the validation, so if there are issues in there, those also need to be fixed).
var sysID = current.getUniqueValue();
var record = new GlideRecord('ps_user_details');
record.addQuery('perimeter_number', sysID);
record.query();
if(!record){
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 06:10 AM
Hi Mark,
I run the above code but it is not working, though it is not throwing any error, but it is not pushing any new record as well on the new table. Don't know why the validation is not working, without it is working everytime but creating multiple duplicate records.
Regards
Souvick