Reference field in transform map does not accept display name

Alison11
Mega Expert

Hello,

 

I'm currently making a transform map to bulk upload requests - requests are already being inserted however, I need the ff requirements:

  1. Link the request to an existing Incident (scoped app)
  2. Get the "requested for" value from the source file (excel)

 

My issue now is that the transform map doesn't accept the display values from the excel file and instead only accepts it if the source value is the sys_id - which we don't want since other users won't normally get the sys_id of the records themselves.

 

Is this issue mainly because the reference fields are being maintained in the scoped app and my transform map is in the Global app?

 

Thank you in advance!

 

Regards,
Ali

15 REPLIES 15

Harsh Vardhan
Giga Patron

you can use "Use source script" in transform map field mapping , here you will do glide record on user table and get the sys_id of the user and then return that as result . 

 

eg:

 

answer = (function transformEntry(source) {

	// Add your code here
    var gr = new GlideRecord('sys_user');
	gr.addQuery('name',source.<your field name>);
	gr.query();
	if(gr.next())
	return gr.sys_id; // return the value to be put into the target field

})(source);

 

 

Doc link for further details. 

 

https://docs.servicenow.com/bundle/orlando-platform-administration/page/script/server-scripting/task...

Hello,

 

I tried this on the field mapping and onBefore transform script too but it didn't work.

 

I also tried linking both OOB and scoped fields but they still returned blank. The field I need to populate is both in RITM and part of a variable set - not sure if there are additional lines required for this case.

 

find_real_file.png

can you add some screenshot of your transform map ?

are you setting the value on catalog form ? 

 

Hello,

 

Here's my transform map:

find_real_file.png

 

Script for Requested for:

answer = (function transformEntry(source) {

    // Add your code here
    var gr = new GlideRecord("sys_user");
    gr.addQuery("name", source.u_requested_for);
    gr.query();
    if (gr.next()) {
        return gr.sys_id;
    } else return ""; // return the value to be put into the target field

})(source);

 

My onBefore transform script has all the fields in the catalog/source file.