Auto Populate incident details on a multi row variable set on a catalog item

Community Alums
Not applicable

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

 

1 ACCEPTED SOLUTION

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

View solution in original post

6 REPLIES 6

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

Community Alums
Not applicable

Hi Chaitanya,

 

it worked
Thanks for the help.

Thanks and regards

Nasheet Khan

+919955860495