Load Data Map to Reference Field

Susan Davidson
Giga Guru

I am trying to import via Load Data from an excel file.

My source data (excel file) has the following fields:

 

Acquisition methodAsset tagCostFunctional departmentInstalledStateBuildingModelPO numberSerial numberSupport groupEntityLast locationOwning DepartmentProperty CodeUnder WarrantyWarranty expiration

 

I created a transform map to load these to the sn_ent_medical_asset table

 

Everything is loading fine EXCEPT for the Building.

 

In the source file the building is a string

I also have a property number which references the building on the cmn_location table.

 

On the target there is a field labeled Building but it is actually a reference field to cmn_location and field name is location.

 

When i complete the data import the Location field is blank.

 

I have tried - mapping directly

Building to Building (Location) using the name (which matches the entry on the Location table, is active and will match if searched (but does have more than one match)

SusanDavidson_1-1722577655586.png

 

 

Mapping using the property code on the source to the Building(Location) on target and using the u_property_number as the referenced field value (have confirmed that this matches and will always be unique)

SusanDavidson_0-1722577627680.png

 

 

Using a script to do a lookup with a combination of the two above

answer = (function transformEntry(source) {

	// Add your code here
	var gr = new GlideRecord('cmn_location');
	gr.addQuery('name',source.u_building);
	gr.addQuery('u_property_number',source.u_property_code);
	gr.query();
	if(gr.next()){
		return gr.sys_id; // return the value to be put into the target field
	}
	
})(source);
 
I even tried just mapping the property code to a property number field on the form (number comes across fine) and setting up a business rule on insert that would set the location.u_property_number field to be same as property number)
 
None of it has worked..it's always blank.
Not even trying to fill the field.
 
Anyone have ANY ideas - this is driving me loopy.
3 REPLIES 3

Mark Manders
Mega Patron

How long is the name? It could be that your excel exceeds the length of the import set table which causes the name to not match on any location name. Can you check on the created import set table if you have the correct information for 'building' there? Are you also sure there aren't any typo's or anything like that?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Thanks for replying. The building is fine in the import table. Not shortening or cut off. 

I have checked that if I just copy it from the excel spreadsheet and search in the UI fir that exact spelling and spacing it is found so no typeos either. 

My instance is updating, but it could be that you are mapping to a name and returning a sys_id from the script? 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark