
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 08:55 AM
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:
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 10:20 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 01:13 AM
Hello
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'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2023 06:03 AM
Were you able to find a working solution?
Nothing I see here works...