- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 02:26 PM
Hi every! My goal is to delete duplicate records in a table. The problem I am running into is that when I run my script. The script deletes both the original and the duplicate record and I cannot get it to not do that. Please help. Here is my script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 03:17 PM
Hi Jalen,
You can add a 'tableRec.orderBy('sys_created_on');' line to order the query results, or use 'tableRec.orderByDesc('field') before the tableRec.query(); line. And then skip the first using "TableRec.next();" before the while loop. Or change the 'while' to 'if' if you want to delete just the first result. You need to determine which of any are "duplicates". see:
And look at the two methods.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 03:17 PM
Hi Jalen,
You can add a 'tableRec.orderBy('sys_created_on');' line to order the query results, or use 'tableRec.orderByDesc('field') before the tableRec.query(); line. And then skip the first using "TableRec.next();" before the while loop. Or change the 'while' to 'if' if you want to delete just the first result. You need to determine which of any are "duplicates". see:
And look at the two methods.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 09:14 AM
Thank you! The created on order by worked for me. That is the piece I was missing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 09:34 PM
Please go through the link given below it may help you