Multi Row Variable Set Scoped App

adam_katulak
Tera Contributor

Hi,

I'm trying to utilize the multi row variable set in my Scoped Application, but I am running into errors attempting to utilize the documented methods (getRow() and getRowCount())

Evaluator: com.glide.script.fencing.MethodNotAllowedException: Function getRowCount is not allowed in scope x_ahho_movable_med
Here is the link to the documentation that discusses these methods and there is no mention of issues within scoped applications.
https://docs.servicenow.com/bundle/london-application-development/page/script/server-scripting/concept/c_ScriptableServiceCatalogVariables.html#d1035105e133

4 REPLIES 4

Rushikesh Mandh
Mega Expert

Hi Adam,

 

I'm facing the same issue. Did you get a solution to this?

mattgerry_TP13
Kilo Expert

Hey Adam-

 

I ran into this same issue and found a workaround that worked for me. When you access the multi row variable set via script it returns a JSON Array. If you use JSON.parse() it will return a Javascript array which then gives us the ability to use the "length" method instead of the "getRowCount()" method. For example, assume your multi row variable set is named "multi_row_variable_set" and there are 2 variables in the set named "name" and "date_of_birth". Let's also assume you are running this script via a business rule. Your script would then look something like the following:

 

var mrvs = current.variables.multi_row_variable_set;
var mrvsArray = JSON.parse(mrvs);
var text = '';
for(i = 0; i < mrvsArray.length; i++){
   text += mrvsArray[i].name + ' - ' + mrvsArray[i].date_of_birth;
}
gs.info(text);
		

 

If the value of the "name" variable is "Matt" and the value of the "date_of_birth" variable is "1980-02-12" then the resulting log statement from the script above would read "Matt - 1980-02-12".

 

I hope this helps!

 

-Matt

Thanks, Mir. This did the trick.

Hey Matt--mind taking a look at this one? Seems like you may have done this based on your response.