Create two records from single row using transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 01:43 PM
Hi
We have an excel file which creates records in alm_hardware table using transform map. Now we want to create two records in the target table from single row. Please let me know how it can be done.
Appreciate your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 11:41 PM
HI @MercBuilding ,
I trust you are doing great.
To create two records in the target table from a single row in the Excel file using a transform map in ServiceNow, you can follow these steps:
Create a new transform map in ServiceNow. Navigate to "System Import Sets" and select "Transform Maps."
Define the source table as "alm_hardware" and map the appropriate fields from the Excel file to the corresponding fields in the target table.
In the transform map, click on the "Advanced" tab and locate the "Create Extensions" section.
Enable the "Create two records" option. This allows you to create two records in the target table from a single row in the source file.
Specify the conditions for splitting the single row into two records. For example, you can use a specific field value or a combination of fields to determine when to split the record.
Save the transform map.
Now, when you perform the import using the transform map, the records in the Excel file will be split into two separate records in the target table based on the conditions defined in the transform map.
Here's an example code snippet to illustrate the process:
var importSetGr = new GlideImportSet();
importSetGr.initialize(); // Initialize the import set
var importSetRowGr = new GlideImportSetRow(importSetGr);
importSetRowGr.setValue('source_table', 'alm_hardware');
// Set other field values as per your requirement
var importSetLoader = new GlideImportSetLoader();
importSetLoader.loadAllSets(); // Load the import set
var transformMapGr = new GlideImportSetMap();
transformMapGr.get('your_transform_map_sys_id').runTransform(importSetRowGr); // Replace 'your_transform_map_sys_id' with the actual sys_id of your transform map
// The records will be created in the target table based on the defined conditions in the transform map
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 01:28 PM
Hi @Amit Gujarathi ,
Thank you so much for your reply but i dont find the 'Advanced' tab in transform maps. Do you mean 'Tranform Scripts' section, please let me know.