How to write On Before Transform script to replace staging table field value with sys id?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2024 09:50 AM
Hi Community,
I want to load below record to staging table but before transforming this data to target table, I want to replace sub region value to sys id as Sub Region is reference field which referencing to region table.
I wrote below On Before Transform Script but not sure if it will work:-

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2024 11:34 AM
Hi,
Is there a reason you must do this before the transformation?
Instead, you could just handle this per the row as they're transforming and address this in your field map itself, just select your source and target fields and then use script and use something similar. Your GlideRecord query, right now, is not efficient as it pulls every single record from that table, then iterates through them looking for the display value to match your source. So, you could use what you have in your onBefore, but Instead, in transformation, you'd want to narrow down the possible records by addQuery to it and searching for the specific data like:
region.addQuery('name', source.u_sub_region);
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!