How to get length of MRVS row count from client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 03:32 PM
Hi,
How can I get length of MRVS row count. I am tried using the below script to get length, I am able to get length in CMS view (alerts are showing correctly).But in Portal, I do not see any alerts if I use JSON.parse, I am able to see alerts incorrectly if i use stringify. Any help??
var mrvs = g_form.getValue('vta_training_details'); // internal name of your MRVS
//alert(mrvs);
var obj = JSON.parse(mrvs);
alert(obj);
var MRVSlength = obj.length;
alert(MRVSlength);
thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2022 10:22 PM
Hi @reddy8055 ,
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
If not reply and share details.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 02:22 AM
Hi @reddy8055 ,
If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
If not reply and share status of the issue.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 09:13 PM
Hi,
I also have similar usecase but JSON.parse is throwing error in console. My usecase is that I want to get the count of inserted rows in mrvs and that value I need to add in a client script of mrvs for some comparisons.
Can someone please help me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 09:19 PM - edited 02-28-2024 09:19 PM
JSON.parse() will throw an error if the thing you're passing into it isn't a valid JSON string, which suggests that either you're not getting the data from your MRVS correctly (ie: make sure you're using the correct internal name when calling `.getValue()`) or your MRVS is empty and has no rows (and you're not handling this scenario). It'd be best if you shared some code and the error.