- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 02:40 AM
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:
On the Cat Item I have created the following Catalog Client Script
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:
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 05:02 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 03:17 AM
check below li in script include,
var arr = [];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 03:21 AM
OK I have done the following replaced the client script with the following:
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
}
}
}
Whether the line var is arr = {}; or arr = [];
I still receive the error on the browser:
There is a JavaScript error in your browser console
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 03:22 AM
Here is the latest script include:
var getAssetDetails = Class.create();
getAssetDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getApp:function(){
var arr = [];
var app = this.getParameter('sysparm_app').split(',');
var dis;
var gr = new GlideRecord('alm_asset'); //Replace cmdb_ci_appl with your table name
gr.addQuery('sys_id','IN',app);
gr.query();
while(gr.next())
{
arr.push(gr.display_name); //Path should be replaced with you field which contains Path on technical system table
}
return arr;
},
type: 'getAssetDetails'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 03:26 AM
Replace your return part with below code,
return JSON.stringify(arr);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 03:28 AM
Updated the Script include to the following:
var getAssetDetails = Class.create();
getAssetDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getApp:function(){
var arr = [];
var app = this.getParameter('sysparm_app').split(',');
var dis;
var gr = new GlideRecord('alm_asset'); //Replace cmdb_ci_appl with your table name
gr.addQuery('sys_id','IN',app);
gr.query();
while(gr.next())
{
arr.push(gr.display_name); //Path should be replaced with you field which contains Path on technical system table
}
//return arr;
return JSON.stringify(arr);
},
type: 'getAssetDetails'
});
Receiving same error in browser