Populate a reference field (transform map)

Maria DeLaCruz
Tera Guru

Hello,


How can I populate a reference field via import or transform map?   The reference field is caller_id, but the source data contains the caller_id.user_name.   Currently, we are able to type in the user_name in that field, and it is able to find the name.

Thanks,
Maria

1 ACCEPTED SOLUTION

Great!


Okay, now you've hit the main problem with the field being converted to integer - integers don't have prefixed zero's so they are lost.


  1. You can try changing the type of the employee ID field to String with a length of 40, but chances are this won't work. (You could also try deleting the column and re-adding it but this will likely also have issues.)
  2. If the employee ID's are a predictive length, then you could also pad the employee ID with the missing zeroes if it's not the right length, but this won't work for you because of the ID's that start with a letter:

    var id = '' + gr.u_employee_id;


    if (id.length < 6) id = ('000000' + id).substr(-6);


    answer = id;


  3. The only other option is to start your import table from scratch and prevent ServiceNow from interpreting the field type to anything other than a string (Consider if you might also need to do this for other fields as well). To do this, simply take your spreadsheet and delete all the rows except for the header and the first data row and change any fields that look like numbers and make them a string. E.g. Employee ID might have 005834 so just make it 'abc' to force it to be a String. Now run through a new import setup with this file but don't bother actually doing the transform, and once you've set everything up again you should find everything works ok. Doing this also means you won't need any conversion scripts for the employee id to user_name field because it's a string to string match.

View solution in original post

14 REPLIES 14

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You should be able to use the Referenced value field name field to set the caller_id field by the userid.


9eab69d42d.png


Hi Brad,



Thanks for the response.   So, I tried this, and my caller field shows some number instead of the Caller's name:



1.JPG




This is how I setup the field map:



2.jpg



Please advise.



Thanks,
Maria


Is employee id the correct field from your source table?


Yes.



Attached is the source file.