Select User and list assets assigned (Catalog Form)

Chris Richie
Tera Contributor

Hello - I'm working on an offboarding form and would like it that when a user is selected, it will output their list of assets and eventually list it in the RITM and/or TASK Description.

Currently I have it setup as a list collector which the user filling out the form needs to select the available assets, but I would prefer it would simply list all of them and attach to record.  Can you assist me with that please?

Here is a few screenshots:

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

@Chris Richie please replace the script include like below

You need to write your function always inside prototype like below

var ScriptIncludeName = Class.create();
ScriptIncludeName.prototype = Object.extendsObject(AbstractAjaxProcessor, {
populateAssets: function() {

var arr = [];

var gr = new GlideRecord("alm_hardware"); 
gr.addQuery('assigned_to', this.getParameter('sysparm_employee'));
gr.query();
while(gr.next()) {
arr.push(gr.sys_id.toString()); //give your owner field name here
}

return arr.join(',');
},
    type: 'ScriptIncludeName'
});

Please mark my response correct or helpful if it helps you

View solution in original post

11 REPLIES 11

Hello @SUMANTH DOSAPATI ,

 

Can you please guide me what value should be added in  below line?

arr.push(gr.sys_id.toString()); //give your owner field name here

I've followed the instruction above but still I get the value for the assigned asset populated automatically.

 

Here is how my "Catalog Client Scripts" looks like :

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

var ga = new GlideAjax("ToGetAssetDetail"); //give your client callable script include name which you are going to create in next steps
ga.addParam('sysparm_name', 'populateAssets');
ga.addParam('sysparm_employee', newValue); 
ga.getXML(callback);

}

function callback(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue("asset_owned",answer); //update your assets assigned variable name here
}

 

asset_owned is the variable name for the asset owned by the user.

 

And here is my "Script Include" - named ToGetAssetDetail looks like :

var ToGetAssetDetail = Class.create();
ToGetAssetDetail.prototype = Object.extendsObject(AbstractAjaxProcessor, {

populateAssets: function() {

var arr = [];

var gr = new GlideRecord("alm_hardware"); 
gr.addQuery('assigned_to', this.getParameter('sysparm_employee'));
gr.query();
while(gr.next()) {
arr.push(gr.sys_id.toString()); //give your owner field name here
}

return arr.join(',');
},
	
    type: 'ToGetAssetDetail'
});

Lon Landry4
Mega Sage

Were you able to find a working solution?
Nothing I see here works...