How do I set the sys_id value in the source script of a field mapping?

sattar3
Tera Contributor

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

@Ankur Bawiskar 

Thanks,

Shaik

6 REPLIES 6

@sattar3 

not sure why you don't have rights to create onBefore but you have right to have source field map script

in field map script query target table with that sysId and return sysId of record, in referenced value field name give sys_id as field

💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏

Ramkumar Thanga
Mega Sage

 Are you able to try with a onBefore Transform script ?

 

Make sure you have the right roles either admin or import_admin.

 

Then check if you are in the same scope as the transform map.

 

Try with this (Alternative Path)
If the New button is missing and you cannot restore it, you can create the script directly from the Transform Script table:

Check of you have access to this table by typing sys_transform_script.list in the navigation filter at the top left and press Enter.
If you have access check for the New button at the top right corner of the table.

If NOT then check your roles.

If Yes,

Click New.
Fill out the fields:
Name: Give your script a descriptive name (e.g., Server mapping).
Transform Map: Select your target transform map from the lookup.
When: Choose onBefore from the dropdown.
Script: Write your code (target.u_osi_server = source.u_field;)