GlideList and Transform Map

Mark_Didrikson
ServiceNow Employee
ServiceNow Employee

Hello,

I am trying to set up a Transform Map to import data into a Glide List field. The filed is use to store platform information (Windows 7, Windows 8, etc.).

I have a set of four records I am trying to import from a spreadsheet:

Name Platform
CLV MAIN 5.0 WINDOWS 7
CLV MAIN 5.0 WINDOWS 8
CLV MAIN 5.0 WINDOWS VISTA
CLV MAIN 5.0 WINDOWS XP

My Transform Map only seems to pick the last item in the list and add it to the Glide List. Not sure what I am doing wrong. Seems pretty straightforward.

Here is my script:



// PLATFORMS

var plat = source.u_platform;

var gr = new GlideRecord('platforms');
gr.addQuery('description',plat);
gr.query();

while (gr.next()) {
if(target.u_platform != "") {
target.u_platform = (target.u_platform + "," + gr.sys_id);
} else {
target.u_platform = gr.sys_id;
}
}


Any help is greatly appreciated.

Thanks!

2 REPLIES 2

Mark_Didrikson
ServiceNow Employee
ServiceNow Employee

To clarify, there are two fields in my spreadsheet:

Name
Platform

The Name value is the same for all: CLV MAIN 5.0 (I coalesce on this field)
The Platform values I want added to the Glide List are: WINDOWS 7, WINDOWS 8, WINDOWS VISTA, WINDOWS XP

Thanks!


Mark_Didrikson
ServiceNow Employee
ServiceNow Employee

I got this figured out. I used the ListUtil Script Include created by Chuck Tomasi and had to shift the following line of code to an onBefore script.

http://community.servicenow.com/blog/ctomasi/managing-glide-lists




var lu = new ListUtil(target.u_platform);



Here is the script within the Transform Map:



var plat = source.u_platform;

//var lu = new ListUtil(target.u_platform);

var gr = new GlideRecord('platforms');
gr.addQuery('description',plat);
gr.query();

while (gr.next()) {
lu.addToList(gr.sys_id);
target.u_platform = lu.getList();
}


Thanks!