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

@Jaspal Singh  I tried below OnBefore script but still "Comments and Work notes" is showing as empty .

Please guide.

find_real_file.png

var caseworknotes;
    var inci = new GlideRecord('table_name');
    inci.addQuery('correlation_id', source.u_historical_case_no);
    inci.query();
    if (inci.next) {
        caseworknotes = source.u_work_notes;
        target.work_notes = caseworknotes.toString();
    }
	

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

 

Couple of checks.

1. Line1

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

is missing

2. 

var inci = new GlideRecord('table_name');

hope you are passing correct table name instead of table_name

3. 

  if (inci.next) {

has a typo. it should be

  if (inci.next()) {

@Jaspal Singh I have corrected the code in the OnBefore script but still I am not able to populate in Worknotes. 

I am using the correct table name , but I masked it here.

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

	var caseworknotes;
    var inci = new GlideRecord('table_name');
    inci.addQuery('correlation_id', source.u_historical_case_no);
    inci.query();
    if (inci.next()) {
        caseworknotes = source.u_work_notes;
        target.work_notes = caseworknotes.toString();
    }
	

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

lholl
Tera Contributor

You've probably figured this out but in case anyone else is wondering:

You have to enable Business Rules on your transform map. Good luck!