shouvik
ServiceNow Employee
ServiceNow Employee

Catalog Variables are stored in a table item_option_new.

The variables are associated either to a catalog item or to a variable set.

The association between catalog item and variable set is stored in io_set_item.

 

Create a Database view on the two tables like this

 

find_real_file.png

 

Expose the following fields in each table

Table: item_option_new

find_real_file.png

 

Table: io_set_item

        find_real_file.png

 

Note the whereclause.

 

Try the database view and have the following filter and list layout. (Note: The two Catalog Item comes from the different tables in the view)

 

find_real_file.png

 

Note: Multi Row Variable Set Values cant be achieved by this method 

 

Another solution is to get it via query. Here is a simple query to do the same.

 https://docs.servicenow.com/bundle/madrid-application-development/page/script/server-scripting/conce...

 

var gr = new GlideRecord('sc_req_item'); 
if (gr.get('635a1f5387320300e0ef0cf888cb0b73')) { 
    var variables = gr.variables.getElements(); 
    for (var i=0;i<variables.length;i++) { 
        var question = variables[i].getQuestion(); 
        gs.log(question.getLabel() + ":" + question.getValue()) 
    } 
}

From New York to get values of table variable

var gr = new GlideRecord('sc_req_item');
gr.get('02c38dcd87013300e0ef0cf888cb0bb2');

var vars = gr.variables.getElements(true); //Get Table Variables as well

for (var i=0; i<vars.length; i++) {
	var v = vars[i];
	if (v.isMultiRow()) {
		var rows = v.getRows();
		for (var j=0; j<v.getRowCount(); j++) {
			var row = rows[j];
			var cells = row.getCells();
			for (var k=0; k<cells.length; k++) {
				var cell = cells[k];
				gs.info(cell.getLabel() + ":" + cell.getCellDisplayValue())
			}
		}
	}
}

 

 

2 Comments