Get count of records in list collector
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 10:59 PM
Hi Team,
I'm using a list collector in my record producer. Is there a way to determine the number of records in the list collector on a client script?
I'm populating the value of list collector through a Script Include (not client callable) .
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 11:08 PM
var x = g_form.getValue('field_name');
x = x.split(",");
console.log(x.length);
Here's an example which get's the value of a field called "field_name".
This would be a comma separated list of sys_ids (value_1,value_2,value_3).
We then split it into an array using split(",") and then we count the length of the array = the elements in it.
Here console log would return 3 if we had three items in the List Collector.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 11:33 PM
This would work for the records that are selected in list collector, but what I want is to determine the total records in the list collector.
Overall objective is to check if the user has selected all the values in a list collector, if he selected all the values I want to redirect him to a new catalog item.
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 12:37 AM
For that you'd have to use GlideAjax and query the reference table with the same query that the List Collector uses. That way you can fetch the count first and then compare the selected values to it.
I doubt there's any better way for that.
On the other hand do you need to have all selected or can you just set a hard coded limit or is the other form only for every selection rather than for many?
IMO it would be easier to just say if user selects X or more options then they probably need to use form Y.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 11:09 PM
Dear @JohnnySnow
You can use split value in the list collector and use counter or Length to get the values of the records
- Kailas