ServiceNow Service Catalog Variables or Record Producer Variables in Client Script Using Scratchpad
see also:
display business rule
var varsArr = [];
var variables = current.variables.getElements();
for (var i = 0; i < variables.length; i++) {
var question = variables[i].getQuestion();
varsArr.push(question.getName() + ":" + question.getLabel() + ":" + question.getValue());
}
g_scratchpad.rpvariables = varsArr.toString();
//for multi row
var varsMR = current.variables.getElements(true);
var varsMR_Arr = [];
for (var i = 0; i < varsMR.length; i++) {
var now_V = varsMR[i];
if (now_V.isMultiRow()) {
var rows = now_V.getRows();
for (var j = 0; j < now_V.getRowCount(); j++) {
var row = rows[j];
var cells = row.getCells();
for (var k = 0; k < cells.length; k++) {
var cell = cells[k];
varsMR_Arr.push(cell.getLabel() + ":" + cell.getCellDisplayValue());
}
}
}
}
client script
if (g_scratchpad.rpvariables != '') {
var sVarsArr = g_scratchpad.rpvariables.split(',');
var iCounter = 0;
for (i = 0; i < sVarsArr.length; i++) {
iCounter++;
var varElements = sVarsArr[i].split(':');
if (iCounter > 20) {
if (varElements[0].toString() != '') {
alert(varElements[0] + '--' + varElements[1] + '--' + varElements[2]);
}
//g_form.setVisible(varElements[0], false);
}
}
Comments
Post a Comment