Iterate list other than defined as source for list widget

Iterate list other than defined as source for list widget

  

I want to fetch data from an integer list (say list A) into a list widget, which already uses data from a structure list (say list B) obtained from a REST API as source for iteration. I am thinking of using CurrentRowNumber of this list in the integer list for index, but I am not getting the syntax correct in the expression editor. Is my approach correct? Is there any other method to do it? Any help is appreciated!

PS: I am a beginner working on a weather mobile app

EDIT: Trying to resolve ambiguity in my question

List A is not a subset of list B. List B is a list of structures of hourly weather data from a weather API. List A is an integer list local variable, containing integers as references to weather icons stored in my resource folder using some logic. I want to display appropriate icon based on weather data in list B. So say if List B.Current.WeatherIcon = 5, then it should match with List A.5 (and almost every icon will be different due to varying weather). And list B is the source list for my list widget, so I am unable to iterate through list A in the widget.

Hi,


could you provide some more context. For example a simple oml, because now we are simply guessing what you actually want to achieve

Shamli,

Let me see if I understood.

You are fetching data from REST. It is a list of structures where one of the attributes is a list of integers. You pass this integer list as source to a List Records in screen? And now wants to iterate this list?

What's your purpose? What do you wants to do exactly?

Do you know how "foreach" works? Are you trying to iterate the original list?  

Cheers.

Eduardo Jauch wrote:

Shamli,

Let me see if I understood.

You are fetching data from REST. It is a list of structures where one of the attributes is a list of integers. You pass this integer list as source to a List Records in screen? And now wants to iterate this list?

What's your purpose? What do you wants to do exactly?

Do you know how "foreach" works? Are you trying to iterate the original list?  

Cheers.


I have edited my question. Let me know if my question is clear now

Hi Shamli,

Given your edited question, I'd say in the Preparation you iterate through ListB and do the mapping with List A (probably assigning the value of ListA[5] to some attribute of ListB.Current), then your List widget will have all the information it needs...

Solution

HUm...

So, you want to fetch the right icon (pointed in A), for every line of B?
How are you fetching the icon itself? It is an image? What are you using to show it?

If your images are stored as resources, you can use Deploy to Target folder, and than use an image widget to show then.

I would do something like this.

1. Create a function that receives the icon id (like 5 in your example), and than return the address of the image (you can do that if you put the images as resources using deploy to target folder).

2. In the list in the screen, use an image widget set to external image, and in the source property set the function, passing ListRecordsName.List.Current.Weathericon as its argument.

This should do the trick.

Cheers,
Eduardo Jauch


Solution

Eduardo Jauch wrote:

HUm...

So, you want to fetch the right icon (pointed in A), for every line of B?
How are you fetching the icon itself? It is an image? What are you using to show it?

If your images are stored as resources, you can use Deploy to Target folder, and than use an image widget to show then.

I would do something like this.

1. Create a function that receives the icon id (like 5 in your example), and than return the address of the image (you can do that if you put the images as resources using deploy to target folder).

2. In the list in the screen, use an image widget set to external image, and in the source property set the function, passing ListRecordsName.List.Current.Weathericon as its argument.

This should do the trick.

Cheers,
Eduardo Jauch


This will work I guess. But I am unable to see source property of image widget when I choose image type as external URL, where I set the URL to path returned by the client action. How will the client action get called? There is no event to trigger it.

PS: I am working on version 10+ of Outsystems


Hi,

The "source" is the property URL when you set the image Type as External. :)

Cheers.

Eduardo Jauch wrote:

Hi,

The "source" is the property URL when you set the image Type as External. :)

Cheers.

That is all right. Sorry I am still a novice on this platform. All I meant to ask is what event will trigger the action? How does it get called in UI?


Okay I thought it up further, and called this action in my action A which is called on ready. Guess what, it works really well!

Thanks a lot for your help everyone, especially Eduardo!