How do I set the sys_id value in the source script of a field mapping?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
34m ago
Hello Everyone,
I am loading data into a staging table through an inbound payload. One of the staging table fields, serverosi, contains the sys_id of a record from the cmdb_ci_computer table.
During the transform, I need to populate the target table field u_osi_server, which is a reference field to cmdb_ci_computer.
My requirement is to use the sys_id stored in the staging table field serverosi and populate the corresponding reference field u_osi_server in the target table.
What is the correct approach to achieve this in a Field Map Source Script or Transform Map? Can a reference field be populated directly using the sys_id value from the source field?
target table name: cmdb_ci_vmware_instance
Thanks,
Shaik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
22m ago - last edited 18m ago
@sattar3 Yes. You can populate the reference field u_osi_server on the target table cmdb_ci_vmware_instance directly using the sys_id stored in the staging table field serverosi, provided that the sys_id identifies a valid record in cmdb_ci_computer. A reference field stores the referenced record's sys_id internally. You do not need to query the cmdb_ci_computer table just to resolve the reference if you already have the correct sys_id. Ensure that the reference table (configured on the target dictionary field). ot required if the source value already contains the correct sysId.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9m ago
@Ramkumar Thanga thanks for the reply.
I tried it, but not working.
Could you please provide the correct source script?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4m ago
use onBefore transform script and set the value
target.u_osi_server = source.u_field;
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
