How to access Multi-row variable set variables in catalog client script

Tamoghna
Kilo Contributor

How to access Multi-row variable set variables in catalog client script:

So the requirement is to implemente a validation while adding rows to multi row variable set so that duplicate entries are not added to the variable set table.

Is there any internal table at the back end that stores the added rows, which we can query during addition of rows.

Business scenario is: if we have added Server1 in first row, we do not want to allow user to enter Server1 again in the next rows.

 

Please let us know how can we access the added rows / variables while adding a new row.

 

Thanks in advance!

 

4 REPLIES 4

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

have a look at this article, it will be very useful for you!

Scripting the Multi-row Variable Set

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

Jace Benson
Mega Sage

I can only seem to trigger a check on the change of another non-table variable.  It works if I do this.

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

	function dedup(arr) {
		var servers = [];
		var returnArr = arr.filter(function(row){
			if(servers.indexOf(row.question_1)<0){
				servers.push(row.question_1);
				return row;
			} else {
				// row already entered
				//console.log('row already exists with that variable');
			}      
		});
		return returnArr;
	}
	//console.log(JSON.parse(g_form.getValue("multirow_variable_set")));
	console.log(g_form.getValue("multirow_variable_set"));
	var deduped = dedup(JSON.parse(g_form.getValue("multirow_variable_set")));

	console.log(deduped); // [ {a: 1}, [1, 2] ]
	g_form.setValue("multirow_variable_set",JSON.stringify(deduped));
}

 

https://www.youtube.com/watch?v=c3gi1lJMYqE&feature=youtu.be

Hi,

We need to run a script when clicked on "Close" buttn in multirow variable set.

OnSubmit script in multirow variable script is not supported.

 

Thanks in advance!

I havent inspected how the "Close" button works, but I have a feeling, it's not going to be accessible on SP.