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

Ankur Bawiskar
Tera Patron
Tera Patron

@Takumi Togashi 

So are you saying if count is 3 it means only 3 rows can be added by user?

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

@Ankur Bawiskar 

No, for example, if 4 rows are added to a multi-row variable set, I want the "count result" variable in the image to be automatically populated with "4".

@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

Aniket Bhanse
Tera Guru

@Takumi Togashi 

You want to implement this on load?

 

And from where you will be fetching the data? Do you have any table which is storing the data which you want to populate in the multi row variable set?

 

Thanks

Aniket