- int COUNT_BY_ID_ALT(list PRI_LIST)
- {
- //use samples CRA,BIR should be 263
- n = 0;
- UNIQUE_ID_LIST = List();
- for each element in input.PRI_LIST
- {
- ID_LIST = (SUBSCRIBERS[LISTS.contains(element)].ID).getall();
- for each ID_element in ID_LIST
- {
- //makes unique list of ID's
- if (!UNIQUE_ID_LIST.contains(ID_element))
- {
- UNIQUE_ID_LIST.add(ID_element);
- }
- }
- }
- return UNIQUE_ID_LIST.size();
- }
And Function 2
- int COUNT_BY_ID(list PRI_LIST)
- {
- //use samples CRA,BIR should be 263
- n = 0;
- UNIQUE_ID_LIST = List:String();
- for each element in input.PRI_LIST
- {
- ID_LIST = (SUBSCRIBERS[LISTS.contains(element)].ID).getall();
- for each ID_element in ID_LIST
- {
- //makes unique list of ID's
- if (!UNIQUE_ID_LIST.contains(ID_element))
- {
- UNIQUE_ID_LIST.add(ID_element.toString());
- }
- }
- }
- return UNIQUE_ID_LIST.size();
- }
Function 1 returns the expected result from my test set (263) while Function 2 returns a larger number (275). Analysis of the results shows Function 2's "
makes unique list of ID's" loop is duplicating some strings in a predictable fashion. The only difference between these two functions is that in Function 2, I'm treating record ID numbers as strings.
Line 13 in Function 2 is where the thing fails. If I make it
- if (!UNIQUE_ID_LIST.contains(ID_element.toString()))
then the function works. This is why I think there's an internal bug. Either Creator should tell me that I cannot compare strings to long or the internal string comparison is broken on your server's side.
In any case, I'm using Function 1 in my app, but I thought you should know about this.
Cheers,
John Whitney