Get count of records in list collector

JohnnySnow
Kilo Sage

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) .

 

 

Thanks
Johnny

Please mark this response as correct or helpful if it assisted you with your question.
7 REPLIES 7

Weird
Mega Sage
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.

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.

Thanks
Johnny

Please mark this response as correct or helpful if it assisted you with your question.

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.

KB18
Tera Guru
Tera Guru

Dear @JohnnySnow 

You can use split value in the list collector and use counter or Length to get the values of the records

 

KB18_0-1684217350212.png

 

Please hit the thumb Icon and mark as correct in case I help you with your query!!!
- Kailas