How to compare source table and target table records in transform map.

vishaljaiswal
Giga Expert

Requirement: How to compare source table and target table records in transform map and the records Active True in Target table if that is new in target table?

3 REPLIES 3

Akash4
Kilo Sage
Kilo Sage

Hello Vishal,

There is a solution already available from this link: 

https://www.servicenow.com/community/developer-forum/how-to-compare-the-source-and-target-table-data...

 

 

Hope this helps!
Regards, Akash
_____________________________________________________________________________
Please mark it as helpful 👍 or Accept Solution ✔️ based on the response to your query.

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.

This is a different requirement.

Satishkumar B
Giga Sage
Giga Sage

Hi @vishaljaiswal 

for comparing records between a source table and a target table in ServiceNow using a transform map, and ensuring new records in the target table are marked as active:

1. Transform Map Setup:
- Create or edit a transform map in ServiceNow to map fields from the source table to the target table.

2. Field Mapping:
- Ensure the `active` field (or relevant fields) in the target table is mapped correctly in the transform map.

3. Scripting (if needed):
- Use scripting in the transform map to check if the record exists in the target table based on a unique identifier.
- Example script to set `active` field for new records:


var grTarget = new GlideRecord('target_table_name');
grTarget.addQuery('unique_field', source_record.unique_field);
grTarget.query();

if (!grTarget.next()) {
target.active = true;
}

 

This ensures that new records imported from the source table are appropriately marked as active in the target table based on your specified conditions. Adjust the script and field mappings according to your specific data requirements.

 

…………………………………………..
Mark it helpful 👍and Accept Solution !! If this helps you to understand.