Getting the duplicate entry
Options
- 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.
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();
while (gr.next()) {
gs.print(gr.number);
gr.state=8;
}
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 12:58 AM
Please 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();
}
This will definitely helps you to resolved your issue. Let me know in case you need to understand the flow or you can DM on LinkedIn.
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Best Regards,
Krushna Birla