duplicate records iteration
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 12:30 PM
Hi Guys, I have a custom table 'ABC' that has two reference records pointing to another tables 'XY' and 'GH'. The question is based on matching values that refers to XY (in ABC table) need to iterate and check the values referring to GH. Please suggest how to proceed. Thanks.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 01:07 PM
Hi @Praveen75
you will likely need to utilize a script,
var abcGR = new GlideRecord(‘ABC’);
// Query for records in the ABC table
abcGR.query(); // Add any necessary query filters using .addQuery()
// Loop through the returned records
while (abcGR.next()) {
// Access the reference field that points to XY
var xyRef = abcGR.getValue(‘xy_reference_field’); // Replace ‘xy_reference_field’ with the actual field name
// Optionally get the whole XY record
var xyRecord = abcGR.xy_reference_field.getRefRecord();
if (xyRecord.next()) {
// You can now work with this XY record directly
}
// Similarly, access the GH reference
var ghRef = abcGR.getValue(‘gh_reference_field’); // Replace ‘gh_reference_field’ with the actual field name
// Optionally get the whole GH record
var ghRecord = abcGR.gh_reference_field.getRefRecord();
if (ghRecord.next()) {
// You can now work with this GH record directly
}
// Your logic here to compare, check or manipulate records
// Example: if(xyRef == something && ghRef == somethingElse){ //do something }
}
Please mark it helpful and accepted if this helps you in somehow. This will help both community and me.
Thanks and Regards
Deepak Sharma