- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 12:57 AM
Hi Team,
I have a scenario where I want to auto populate list of incident records on multi row variable set that i have created on a catalog item,and i want to do it on load of the catalog item.
below are the details of it.
multi row variable set variable name: incident_details
var1 name:incident_short_description
var2 name:incident_description
var1 will have the short description of incident records
var2 will have description of incident records.
i want only the active incident details.
Request you to help on this requirement.
Thanks and regards
Nasheet Khan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2024 02:18 AM
try this out
Client callable Script Inlcude
var CatalogpostSol = Class.create();
CatalogpostSol.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getIncidetns:function(){
var res = [];
var incGr = new GlideRecord('incident');
incGr.addEncodedQuery('ORDERBYDESCsys_created_on'); // replace the encodedquery if needed
incGr.setLimit(5);
incGr.query();
while(incGr.next()){
var shortD = incGr.getValue('short_description');
var desc = incGr.getValue('description');
var tempObj = {};
tempObj.add_row_onload_to_multi_row_variable_set /*the variable name maps to SD*/ = shortD?shortD:'';
tempObj.column2 /*the variable name maps to description*/= desc?desc:'';
res.push(tempObj);
}
return JSON.stringify(res);
},
type: 'CatalogpostSol'
});
OnLoad Catalog Client Script
function onLoad() {
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('CatalogpostSol');
ga.addParam('sysparm_name','getIncidetns');
ga.getXMLAnswer(function(ans){
g_form.setValue('catalogpostsol'/*interName of the variable set*/,ans);
});
}
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2024 02:18 AM
try this out
Client callable Script Inlcude
var CatalogpostSol = Class.create();
CatalogpostSol.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getIncidetns:function(){
var res = [];
var incGr = new GlideRecord('incident');
incGr.addEncodedQuery('ORDERBYDESCsys_created_on'); // replace the encodedquery if needed
incGr.setLimit(5);
incGr.query();
while(incGr.next()){
var shortD = incGr.getValue('short_description');
var desc = incGr.getValue('description');
var tempObj = {};
tempObj.add_row_onload_to_multi_row_variable_set /*the variable name maps to SD*/ = shortD?shortD:'';
tempObj.column2 /*the variable name maps to description*/= desc?desc:'';
res.push(tempObj);
}
return JSON.stringify(res);
},
type: 'CatalogpostSol'
});
OnLoad Catalog Client Script
function onLoad() {
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('CatalogpostSol');
ga.addParam('sysparm_name','getIncidetns');
ga.getXMLAnswer(function(ans){
g_form.setValue('catalogpostsol'/*interName of the variable set*/,ans);
});
}
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2024 04:54 AM
Hi Chaitanya,
it worked
Thanks for the help.
Thanks and regards
Nasheet Khan
+919955860495