Getting the duplicate entry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 06:33 AM
We a custom table u_pets, when certain conditions match the new entry will be treated as duplicate. Now, how change the status of all records created except the first one to duplicate. Below is my script that is returning all record matching condition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 07:10 AM
Try this
var gr = new GlideRecord('u_pets');
gr.addEncodedQuery('case_id=f4fe7db01b439585d8cd4bcb01^amount=100');
gr.addQuery('sys_created_on', '>', gs.daysAgo(30));
gr.orderBy('sys_created_on');
gr.query();
gr.next();//Skip the first record
while (gr.next()) {
gs.print(gr.number);
gr.state=8;
//gr.update();
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 07:31 AM
This is excluding first record but now the gr.state = 8 update is not happening. Is this related?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 12:44 AM
Uncomment the gr.update() line and run the code.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 02:11 AM
Did you get chance to check my answer?
If your issue is resolved now.
If yes, can you please mark appropriate response as correct for others who may have a similar question in the future and close this unresolved thread.
If not, please let us know if you need any other help
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP