Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Trying to get a widget to act as a first-level validator for my MRVS

thomaskennedy
Kilo Sage

I want to detect duplicate or contradictory entries in my MRVS before releasing the data to a Flow, and to start I want to use client-side JavaScript, Array methods and so on, to catch the most obvious problems. So I want to add a custom variable to my Item, and have it host a widget that $watches the mrvs. This is on my Australia PDI.

 

I added the widget to my item but the client controller never runs, even after stripping out everything but a console statement.

 

Here is what I did. In addition to my mrvs I added a Variable of type Custom.

 

thomaskennedy_0-1791424900990.png

thomaskennedy_1-1791425022028.png

thomaskennedy_2-1791425054776.png

thomaskennedy_3-1791425125077.png

There is nothing under Default Value. I see a few mentions of populating this field as part of this effort, but none are clear enough to be actionable.

thomaskennedy_4-1791425279716.png

The controller:

api.controller = function($scope, $rootScope) {
    var c = this;
    alert( 1 );
    console.log("client controller");
};
 

I started out with a proper $scope.$watch setup and so on, but nothing happened and it showed no sign of monitoring my mrvs, so at length I stripped it down as you see here, but still nothing happens.

 

Have I overlooked something?

 

 

 

1 REPLY 1

palanikumar
Giga Sage

Hi @thomaskennedy 

 

You can use Catalog Client Script and validate the data before submission. Any specific reason for using the Widget?

 

Thank you,

Palani

Thank you,
Palani