- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2022 09:37 AM
I need to display the count of the records submitted in MRVS.
As of above image, the Total Number of USers in Request should be 1, it should be dynamically change when ever new record is added in MRVS or remove existing record from MRVS.
any help would be appreciated.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2022 04:08 PM
Hi,
If it's an option to simply grab the count on submit you could use the following onSubmit script applied to the catalog item:
var mrvsStr = g_form.getValue("mrvs_name");
var mrvsData = JSON.parse(mrvsStr).length;
g_form.setValue("Count", mrvsData);
I also experimented updating the count dynamically like you mention each time a row is added. This onSubmit script works fine when applied to the MRVS itself:
var mrvsStr = parent.g_form.getValue("mrvs_name");
var mrvsData = JSON.parse(mrvsStr).length;
parent.g_form.setValue("Count", mrvsData + 1);
The issue now with this scenario is how to update the count when you remove a row or remove all. I see a few suggestions like the following:
https://community.servicenow.com/community?id=community_question&sys_id=8a612681db8d64103daa1ea66896190a
I guess you could experiment further to see if this works for you.
Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2022 04:08 PM
Hi,
If it's an option to simply grab the count on submit you could use the following onSubmit script applied to the catalog item:
var mrvsStr = g_form.getValue("mrvs_name");
var mrvsData = JSON.parse(mrvsStr).length;
g_form.setValue("Count", mrvsData);
I also experimented updating the count dynamically like you mention each time a row is added. This onSubmit script works fine when applied to the MRVS itself:
var mrvsStr = parent.g_form.getValue("mrvs_name");
var mrvsData = JSON.parse(mrvsStr).length;
parent.g_form.setValue("Count", mrvsData + 1);
The issue now with this scenario is how to update the count when you remove a row or remove all. I see a few suggestions like the following:
https://community.servicenow.com/community?id=community_question&sys_id=8a612681db8d64103daa1ea66896190a
I guess you could experiment further to see if this works for you.
Geoff