How to set the number of rows in a multi row variable set to the item's variables

Takumi Togashi
Tera Expert

I would like to set the number of rows in a multi-row variable set to a variable in a catalog item, how should I implement this?

The requirement is that the value of the corresponding variable ("count result" in the image) is updated when it is added to the multi-line variable set.

TakumiTogashi_0-1699506625068.png

 

1 ACCEPTED SOLUTION

@Takumi Togashi 

for this you need to detect if user clicked add/remove, based on that populate the other variable

check this link and it will help you to detect and then modify it to populate the count variable

MRVS detect when a row is removed or deleted 

OR

Why not set that variable after submitting RITM? it would be much simpler then, anyhow you are keeping that variable as readonly

If using workflow then use workflow run script and set it like this

var parsedData = JSON.parse(current.variables.mrvsVariableSetName);

current.variables.count = parsedData.length;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

I would like to update the "count result" value each time a row is added to the multi row variable set, I believe this will be implemented in an onSubmit catalog client script within the multi-line variable set.

I tried to create a script based on the following article but it did not work.

https://www.servicenow.com/community/developer-forum/get-mrvs-row-count-onsubmit/m-p/1545351

TakumiTogashi_0-1699507959699.png