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.

HOW TO DO THAT?
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.

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 $scope.page.g_form.getValue(mrvsName);
}, function(value) {
// Action when change
g_form = $scope.page.g_form;
if (value) {
g_form.setDisplay('json_output',true); // Field name needs to show/hide
} else {
g_form.setDisplay('json_output',false);
}
});
};
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:
JSON.parse(value)
This way will convert to array object that we can manage to control easier

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