importing data for 2 different tables, 2nd table data should get imported by coping 1st table data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 07:29 AM
Hi,
I would like to get solution for below request.
We have excel data to be imported to 2 different tables. 2nd table data should get imported by coping details of 1st table. Also we have unique filed. While we transform, system should check for unique field in 1st table and if this unique field record is available then it should pick that record and insert to the 2nd table along with other details in excel data.
I have tried this configuration as below and didn't work. Records are not getting picked from 1st table and inserted to 2nd table.
- Created import set table
- Created Transform map for 2 tables
- Written transform script in 2nd table transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 09:10 AM
transform map for 2nd table should be with higher order
check this link
Import multiple tables at the same time and create relationship among them
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 06:52 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 11:42 PM
Hi Ankur,
Yes i have given order for 1st table as 100 and 2nd table as 300. But it didn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 11:48 PM
I have given the transform script as below,
(function transformEntry(source, target, map, log, isUpdate) {
// Get the unique field value
var purchaseorderID = source.u_description_of_transaction;
// Look up the corresponding cost_plan record
var costPlanGr = new GlideRecord('cost_plan');
costPlanGr.addQuery('u_po_id', purchaseorderID);
costPlanGr.query();
if (costPlanGr.next()) {
// Map fields from cost_plan to fm_expense_line
target.u_po_number = costPlanGr.u_po_id;
target.cost_plan = costPlanGr.name;
target.resource_type = costPlanGr.resource_type;
// Map other fields as needed
}
// Map fields from the source to the target for fm_expense_line
target.u_po_number = source.u_description_of_transaction;
target.resource_type = source.u_cost_type_description;
target.process_date = source.u_booking_date;
target.cost_center = source.u_cost_center;
target.u_account_type = source.u_account_type;
target.u_supplier = source.u_name_of_counterparty;
// Map other fields as needed
})();
Here 1st table is cost_plan, 2nd table is fm_expense_line and unique field is PO ID
u_po_id in cost_plan
u_po_number in fm_expense_line