Search and return an element from a list
Application Type
Mobile

Hello everybody,

I have list of products which contains ID, name, position etc called lets say List1 and in my app I have a QR scanner. When you scan a QR code you will get the ID and position of a specific product and this is saved into a variable, lets say var1. How can I make a search into my list(List1) using this variable var1, find the right product and return all the information regarding this product and show it in the screen?

I thank you in advance.

Kind regards,

Gerantina

mvp_badge
MVP
Solution

Hi Gerantina,


You can use the ListIndexOf action from System to get the position of the element in the list using your Product Id as a filter in the Condition parameter.

 

Afterwards, you'll get the Position of that element in the list (you'll get -1 if no element is found) and you can use that position to fetch the record from the list using the syntax List[<Position>] like on the example below:



And then use this record to display information on the screen.


Hope it helps.


Kind Regards,
João

Hi @João Marques,


thank you very much for the suggestion. The first part worked. But I try ListName[ListIndexOf.Position] I get an error : Can't identify 'ListName' in the expression. I tried also to put the ListIndexOf.Position as a filter in the list and then show only the one row after is filtered but when I tried to display it to the user it wasn't displaying anything. I don't know what the problem could be. 

Do you have any suggestion regarding this?


I thank you in advance. 

Kind regards,

Gerantina

Champion

Hi

I don't understand what is the position attribute stands for.

if you sure onlyone record will match the condition, you can use ListIndexOf as João suggested.

if there is possible to match multiple record please consider use ListFilter.

Kind Regards,

Hi @João Marques , Hi @Tom Zhao ,

thank you for your answer. I will try it and give you feedback. These "products" are actually machines so the position is important. The position is a string that consists in letters and numbers. Is there a way also to search the list by using this string(the position string)?

Champion

Hi

Regardless which action you are using, the condition should be Id = var1.Id and position = var1.position.

Kind Regards,

mvp_badge
MVP

Hi Gerantina,


You can use the property condition to apply your filter in the ListIndex_Of action. This filter may be the product id or another field (you mention a filter by position) in order to identify the row of the list so you can get the details from that position.


Kind Regards,
João

Hi Gerantina, 

i think ListIndex_Of action is best as you mention  by @João Marques .


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.