Filter an aggregrate with a list of comma separated string

Hi All,

1. I am passing a string to another page with comma separated values. Can anyone tell me how can I exclude last comma from the string. Ex : "London,Paris,Newyork ,". How to exclude the comma after Newyork. Using the below code snippet.

  

The Assignment operator is containing the value :


SyntaxEditor Code Snippet

SelectedItems+ListFilter.FilteredList.Current.RetailItemDetails.Id+","


2.  In the next page I am trying to display the records in a table based on the selected id's in the previous page. In the preparation I am filtering the aggregrate data with multiple id's through for each loop. But the records are getting over-ride by the last selected id. 


Iterating the loop upto (Since it contains a comma at the end in the comma separated string)

String_Split.List.Length-1

Can anyone please help me how to display the records in the table based on the selected id's in the previous page by filtering multiple id's in the aggregrate through a for each loop. 

Solution

Hi, 

In order to remove your comma at the end of string, try this: 

If(SelectedItems ="", ListFilter.FilteredList.Current.RetailItemDetails.Id,  "," + ListFilter.FilteredList.Current.RetailItemDetails.Id)

For the other page, why not use a SQL query, avoiding the cicle, obtaining all the records at once?


SELECT column_name(s)
FROM table_name
WHERE column_name IN (YOUR_STRING);


Hope this help :)


Patrícia

Solution

Hi Patricia,

Thanks for your help. :-)   I just amended your suggestions a little bit and it worked.

1. To remove the comma at the end of the string

SyntaxEditor Code Snippet

If(SelectedItems ="", SelectedItems+ListFilter.FilteredList.Current.RetailItemDetails.Id,  SelectedItems+"," + ListFilter.FilteredList.Current.RetailItemDetails.Id)


2. Used the SQL query in the preparation 

SyntaxEditor Code Snippet

SELECT {RetailItemDetails}.* from {RetailItemDetails}
where {RetailItemDetails}.[Id] IN (@Input)

passed the comma separated string as a query parameter to the SQL and set the Expand Inline Property to yes. That does it all.

Suprio Roy wrote:

Hi Patricia,

Thanks for your help. :-)   I just amended your suggestions a little bit and it worked.

1. To remove the comma at the end of the string

SyntaxEditor Code Snippet

If(SelectedItems ="", SelectedItems+ListFilter.FilteredList.Current.RetailItemDetails.Id,  SelectedItems+"," + ListFilter.FilteredList.Current.RetailItemDetails.Id)


2. Used the SQL query in the preparation 

SyntaxEditor Code Snippet

SELECT {RetailItemDetails}.* from {RetailItemDetails}
where {RetailItemDetails}.[Id] IN (@Input)

passed the comma separated string as a query parameter to the SQL and set the Expand Inline Property to yes. That does it all.

Hi,

i'm sorry,
I forgot to add the values in SelectedItems, but i'm still glad i helped.

 However, we can still improve this :


If(SelectedItems ="", ListFilter.FilteredList.Current.RetailItemDetails.Id,  SelectedItems+"," + ListFilter.FilteredList.Current.RetailItemDetails.Id)


If, SelectedItems is empty, we just write the Id in variable, otherwise, as it already has values we add the new Id to what already exists.


Have a good week :)