How to populate Worknotes from a file using Transform map

Mrman
Tera Guru

Hi All,

I am using a transform map to import the historic record from an excel sheet in to Service Now using Transform map field mappings.

I am able to populate all other fields but unable to populate the Worknotes on the form , I am using the below script in the field mapping , but it is not showing anything after running transform .

 

I am getting as shown below in Commentsandworknotes section 

 

find_real_file.png

Please guide.

Target field is set as - Work notes and using the below script :

answer = (function transformEntry(source) {

	var enW = source.u_work_notes.toString();
	return enW; // return the value to be put into the target field

})(source);
8 REPLIES 8

sriram35
Kilo Guru

Hi,

 

Are you using the custom work notes field?

 

If you are using existing work notes the backend value is work_notes

 

 

If I have answered your question, please mark my response as correct and helpful.

Thanks,

Sriram

When you create an import set table it creates the fields with u_ in front of the fields.  However I am curious as to why you are using a script instead of just a text field?

Jaspal Singh
Mega Patron
Mega Patron

Hi,

 

Field map script may not work. You need to have an onBefore() script in place to make this work. Remove the field mapping & try below onBefore() script.

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
    var inciworknotes;
    var inci = new GlideRecord('incident');
    inci.addQuery('number', source.number);
    inci.query();
    if (inci.next) {
        inciworknotes = source.u_worknotes;
        target.work_notes = inciworknotes.toString();
    }

})(source, map, log, target);

@Jaspal Singh  I tried the following OnBefore script in the transform map . but did not work . Now I will try the script you mentioned .

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

	target.work_notes = source.u_work_notes.toString();

})(source, map, log, target);