Script Include and List Collector Variable

danielbartholom
Mega Expert

Hi looking for some assistance please - Is this possible?:

I have a Cat Item with 2x fields on it

1) Assets - List Collector variable - Referencing alm_asset
2) Description - Multi Line variable

I have created the following Script Include:

find_real_file.png

 

On the Cat Item I have created the following Catalog Client Script

find_real_file.png

 Basically what this doing when you select an Asset on the cat item it is pulling back the display name and serial number to the Disposals field:

find_real_file.png

Is there a way I can edit my scripts so that if multiple assets are selected in the List Collector the display name and serial number will be displayed for each on a new line?

Any assistance would be most appreciated. Happy to share further information if required

Thanks

1 ACCEPTED SOLUTION

Hi,

 

Yes I am looking at it right now and this is exactly what I was after. I updated the code slightly and replaced the comma with \n so each new asset returns on a new line.

Thank you so much for looking into this for me and your full support through to resolution.

Dan

View solution in original post

25 REPLIES 25

I have updated my previous post can you check once and also make changes in client script,

this is not working fine

its returning null

Shweta KHAJAPUR
Tera Guru

In client side use below code just after the var answer,

var myArray = answer.evalJSON();

for(i=0;i<myArray.length;i++){

g_form.setValue('',myArray [i]);

 

}

I hope I have got this correct however is the Client Side script update:

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

//Type appropriate comment here, and begin script below
var ga = new GlideAjax('getAssetDetails') ;
ga.addParam('sysparm_name','getApp');
ga.addParam('sysparm_app',newValue);
ga.getXML(hello);

function hello ()
{
var answer = ga.getAnswer();
var myArray = answer.evalJSON();

for(i=0;i<myArray.length;i++){

g_form.setValue('',myArray [i]);
}
//alert(answer);
g_form.setValue('disposals',answer); //network_path is your variable where you want to store path
}
}

 

I am receiving this when adding an Asset to the list collector

 

There is a JavaScript error in your browser console

Hi,

Try below code,

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
 
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('getAssetDetails') ;
ga.addParam('sysparm_name','getApp');
ga.addParam('sysparm_app',newValue);
ga.getXML(hello);
 
function hello ()
{
var answer = ga.getAnswer();
var myArray = answer.evalJSON();


for(i=0;i<myArray.length-1;i++){


g_form.setValue('disposals',myArray[i]); //network_path is your variable where you want to store path
}


}
}