Confusion regarding target object in OnForeignInsert Transform Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Does target actually point to the referenced table (like sys_user) at runtime in OnForeignInsert?
If yes, why does the script editor still suggest fields from the main target table?
Is this just a limitation of the editor, or am I misunderstanding something about how Transform Map scripts work?
Any clarification would be really helpful. Thanks!
- Labels:
-
Workflow Data Fabric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hi Yuvraj,
Good question — this is a common point of confusion when working with Transform Maps and OnForeignInsert scripts.
A few things you should know:
- What target refers to in OnForeignInsert
Yes — at runtime, target points to the referenced (foreign) table record being created.
Example:
If you are inserting into a reference field pointing to sys_user, then:
target = new record in sys_user
- Why editor shows main target table fields
This is mainly a script editor limitation.
The editor:
- Is context-aware only at Transform Map level
- Assumes target = main target table of the transform
- Does not dynamically switch context for OnForeignInsert
So it continues suggesting fields from the main table even though runtime behavior is different
- What actually happens at runtime
During execution:
- Transform detects missing reference
- Triggers OnForeignInsert
- Creates a new record in referenced table
- target object now represents that record
So your script works correctly even if suggestions look wrong
- Practical example
If reference = caller_id → sys_user:
target.user_name = source.u_email;
target.first_name = source.u_first_name;
target.last_name = source.u_last_name;This will correctly populate sys_user, not the main table
- Best practice (important)
✔ Ignore editor suggestions in this context
✔ Always verify the reference table manually
✔ Use dictionary to confirm field names
