The secret of Multirow Variable Set – ServiceNow MRVS on Change

ServiceNow MRVS Change

In previous part, we have gone through the basic configuration for Multirow Variable Set (MRVS). In this article, I will cover the secret to catch ServiceNow MRVS on Change.

First thing first, what is the requirement?

Situation: We want to show/hide some field whenever one row is inserted in MRVS and hide that field if no rows.

servicenow mrvs on change
Show/Hide Fields when insert/update MRVS


Step 1: Create a custom/macro widget to store your logic script (which is a widget)

In your catalog item/ record producer, create a new variable with type of “Custom” (new name on Quebec or Macro in previous releases.

123 4
Create CUSTOM Variable with logic stored in widget

Step 2: Create a custom widget that stores logic on client side part

The reason we don’t use ‘CLIENT SCRIPT’ since ServiceNow Client Script does not recognize any change of MRVS. Remember to include “$scope” api to use the function $watch to recognize any change made from MRVS.

api.controller=function($scope) {
	/* widget controller */
	var c = this;
	var mrvsName = 'multirow_variable_set_title';
	$scope.$watch(function() {
		return $;
	}, function(value) {
		// Action when change
		g_form = $;
		if (value) {
			g_form.setDisplay('json_output',true); // Field name needs to show/hide
		} else {

What did “Value” object return?

The value of this kind of function returns the value of MRVS (g_form.getValue(mrvsName)). They are stored as a JSON object. So in order to handle it easily, we can use:


This way will convert to array object that we can manage to control easier

image 25

To Sum Up,

We have gone through the way to catch change event from a MRVS, but there is still more tricks we can play with