filter data

  

I want filter based on floor(lantai) input, how do I get Rooms(rom) by floor(lantai)?
to be like an expectation.



Hi Arvin,

I am not sure if I understand your question, but if I do what you need to do is to add a filter to your aggregate where floor(lantai) equals the variable with the floor that you want.

https://www.outsystems.com/help/servicestudio/9.0/Using_Data/aggregates/Filtering_Results.htm

Best regards,

João Nobre

Hi Arvin,

You will have to:

  • have an Aggregate that gets the list of Floors, and then have a different Aggregate where you add a filter by floor (Lantai?). This second Aggregate can be done inside a Block that receives the Floor Id, for instance;

or

  • have a single Aggregate for all rooms on all floors and process the result and split it in multiple lists using your own logic.

Typically the first approach is discouraged, and Service Studio will likely warn you, as Aggregates (even if accessing LocalStorage) have a relevant impact on mobile App performance.

João Nobre wrote:

Hi Arvin,

I am not sure if I understand your question, but if I do what you need to do is to add a filter to your aggregate where floor(lantai) equals the variable with the floor that you want.

https://www.outsystems.com/help/servicestudio/9.0/Using_Data/aggregates/Filtering_Results.htm

Best regards,

João Nobre


I've done filtering data like the example, now how to get the floor list value ?

Jorge Martins wrote:

Hi Arvin,

You will have to:

  • have an Aggregate that gets the list of Floors, and then have a different Aggregate where you add a filter by floor (Lantai?). This second Aggregate can be done inside a Block that receives the Floor Id, for instance;

or

  • have a single Aggregate for all rooms on all floors and process the result and split it in multiple lists using your own logic.

Typically the first approach is discouraged, and Service Studio will likely warn you, as Aggregates (even if accessing LocalStorage) have a relevant impact on mobile App performance.


can you give me a simple example for the logic of the 2nd option ? because my problem is on the logical implementation.



Probably you want to get the value from a user Input from the screen. If so you must have a way that the user inputs the floor value (like an input field or a dropdown) on your screen and a submit button, the input will have a variable associated with it (you can create a local variable and associate it with the input). In the button action you do your aggregate and use the variable associated with the input for filtering.

I think it will be good for you if you take some time to do OutSystems Lessons (that have some good examples of how to start using the platform):

https://www.outsystems.com/learn/

Best regards,

João Nobre

Hi Joao,


but here I don't to take from the dropdown, but I want to take the floor list of the field (lantai), like the picture below: 

Thanks,

Arvin 

Arvin Fairuz wrote:

Jorge Martins wrote:

  • have a single Aggregate for all rooms on all floors and process the result and split it in multiple lists using your own logic.

Typically the first approach is discouraged, and Service Studio will likely warn you, as Aggregates (even if accessing LocalStorage) have a relevant impact on mobile App performance.


can you give me a simple example for the logic of the 2nd option ? because my problem is on the logical implementation.

Here are instructions, and how I would organize the action flow:

  1. Create a new RoomsByFloor structure that has a Floor attribute of type Integer that will hold the floor number, and a Rooms attribute of type List of Text.
  2. Add a Local Variable Floors on your screen of type List of RoomsByFloor.
  3. Add another Local Variable RoomsByFloor of type RoomsByFloor.
  4. On your Preparation, create a GetFloorRooms Aggregate that returns all FloorRoom records, ordered by FloorRoom.Lantai and then by FloorRoom.Rom.
  5. Use the Cycle tool to iterate GetFloorRooms.List.
  6. Add an If tool on the cycle with Condition RoomsByFloor.Floor = GetFloorRooms.List.Current.FloorRoom.Lantai and set its Label to Same Floor?
  7. On the True branch of the If tool, add a ListAppend Action, name it AppendRoom and on the List Input Parameter pass it the RoomsByFloor.Rooms, and on the Element Input Parameter pass it GetFloorRooms.List.Current.FloorRoom.Rom
  8. Connect the ListAppend Action back to the Cycle tool.
  9. On the False branch of the Same Floor? If tool, add another If tool with Condition RoomsByFloor.Floor = "" and set its label to First Floor?
  10. On the False branch of the First Floor? If tool add a ListAppend Action, name it AppendFloor and on the List Input Parameter pass it the Floors, and on the Element Input Parameter pass it RoomsByFloor.
  11. After the AppendFloor Action add a ListClear Action, name it ClearRooms and on the List Input Parameter pass the RoomsByFloor.Rooms.
  12. After the ClearRooms Action add an Assign tool, set its Label to Assign Floor and assign to RoomsByFloor.Floor the value of GetFloorRooms.List.Current.FloorRoom.Lantai.
  13. Connect the Assign tool to the AppendRoom action added in 7.
  14. Connect the True branch of the First Floor? If tool (defined in 9.) to the Assign Floor tool defined in 12.

In the end you will have a list of "floors" (RoomsByFloor), and each "floor" will have a list of rooms on that floor.

You should be able to come up with this short algorithm on your own, logical reasoning is an essential skill for any developer that I encourage you to exercise more (you can find lots of exercises online on algorithms and problem solving)

Jorge Martins wrote:

Arvin Fairuz wrote:

Jorge Martins wrote:

  • have a single Aggregate for all rooms on all floors and process the result and split it in multiple lists using your own logic.

Typically the first approach is discouraged, and Service Studio will likely warn you, as Aggregates (even if accessing LocalStorage) have a relevant impact on mobile App performance.


can you give me a simple example for the logic of the 2nd option ? because my problem is on the logical implementation.

Here are instructions, and how I would organize the action flow:

  1. Create a new RoomsByFloor structure that has a Floor attribute of type Integer that will hold the floor number, and a Rooms attribute of type List of Text.
  2. Add a Local Variable Floors on your screen of type List of RoomsByFloor.
  3. Add another Local Variable RoomsByFloor of type RoomsByFloor.
  4. On your Preparation, create a GetFloorRooms Aggregate that returns all FloorRoom records, ordered by FloorRoom.Lantai and then by FloorRoom.Rom.
  5. Use the Cycle tool to iterate GetFloorRooms.List.
  6. Add an If tool on the cycle with Condition RoomsByFloor.Floor = GetFloorRooms.List.Current.FloorRoom.Lantai and set its Label to Same Floor?
  7. On the True branch of the If tool, add a ListAppend Action, name it AppendRoom and on the List Input Parameter pass it the RoomsByFloor.Rooms, and on the Element Input Parameter pass it GetFloorRooms.List.Current.FloorRoom.Rom
  8. Connect the ListAppend Action back to the Cycle tool.
  9. On the False branch of the Same Floor? If tool, add another If tool with Condition RoomsByFloor.Floor = "" and set its label to First Floor?
  10. On the False branch of the First Floor? If tool add a ListAppend Action, name it AppendFloor and on the List Input Parameter pass it the Floors, and on the Element Input Parameter pass it RoomsByFloor.
  11. After the AppendFloor Action add a ListClear Action, name it ClearRooms and on the List Input Parameter pass the RoomsByFloor.Rooms.
  12. After the ClearRooms Action add an Assign tool, set its Label to Assign Floor and assign to RoomsByFloor.Floor the value of GetFloorRooms.List.Current.FloorRoom.Lantai.
  13. Connect the Assign tool to the AppendRoom action added in 7.
  14. Connect the True branch of the First Floor? If tool (defined in 9.) to the Assign Floor tool defined in 12.

In the end you will have a list of "floors" (RoomsByFloor), and each "floor" will have a list of rooms on that floor.

You should be able to come up with this short algorithm on your own, logical reasoning is an essential skill for any developer that I encourage you to exercise more (you can find lots of exercises online on algorithms and problem solving)


Thanks for the replies Jorge, 

maybe you can share your .oml so I can learn it properly and correctly.




Arvin, I provided detailed instructions and no OML on purpose.

The screenshot I took was after following those instructions to the letter to make sure they were correct. Please try them for yourself, and if you have doubts I can further explain, but I believe providing an OML for this will be counterproductive.

Jorge Martins wrote:

Arvin, I provided detailed instructions and no OML on purpose.

The screenshot I took was after following those instructions to the letter to make sure they were correct. Please try them for yourself, and if you have doubts I can further explain, but I believe providing an OML for this will be counterproductive.

I tried it but why cant I use this append? 


Hi Arvin,

Not only you can, but you actually must... that's described in bullet 7.:

On the True branch of the If tool, add a ListAppend Action, name it AppendRoom and on the ListInput Parameter pass it the RoomsByFloor.Rooms, and on the Element Input Parameter pass it GetFloorRooms.List.Current.FloorRoom.Rom

when you give a name to an Action on the Action Flow, its label changes to reflect the name you've just given it:

You can always select any action in an action flow and will be able to check on the Properties panel on the bottom-right part of Service Studio what is the Action (for the selected Action on the screenshot you'll see the Action property has the value ListAction).

For List manipulating actions, you can actually identify which Action is being used by the Action icons:

  • AppendFloor and AppendRoom have the same Icon (with a little plus sign) that identifies these actions as instances of the ListAppend Action
  • ClearRooms has a different Icon (with several small crosses) that identifies this action as an instance of the ListClear Action

Jorge Martins wrote:

Hi Arvin,

Not only you can, but you actually must... that's described in bullet 7.:

On the True branch of the If tool, add a ListAppend Action, name it AppendRoom and on the ListInput Parameter pass it the RoomsByFloor.Rooms, and on the Element Input Parameter pass it GetFloorRooms.List.Current.FloorRoom.Rom

when you give a name to an Action on the Action Flow, its label changes to reflect the name you've just given it:

You can always select any action in an action flow and will be able to check on the Properties panel on the bottom-right part of Service Studio what is the Action (for the selected Action on the screenshot you'll see the Action property has the value ListAction).

For List manipulating actions, you can actually identify which Action is being used by the Action icons:

  • AppendFloor and AppendRoom have the same Icon (with a little plus sign) that identifies these actions as instances of the ListAppend Action
  • ClearRooms has a different Icon (with several small crosses) that identifies this action as an instance of the ListClear Action

Hi Jorge,

Yes I understand the instructions, but the problem is why I cant use these tools. I cant drag those tools into branch. Not about I cant do it. I dont know why this cant be used.

and the choice is no ListAppend.

Ah, I get it...

You're trying to drag Client Actions to a server-side Action Flow (a Data Action runs on the server, not the device). Scroll down to the Server Actions folder, and you'll see the equivalent Server Actions under the (System) reference, those you will be able to drag to your Action Flow.

If you don't see the actions you need, you may need to go to the "Manage Dependencies..." popup and add those Server Actions from (System).

Jorge Martins wrote:

Ah, I get it...

You're trying to drag Client Actions to a server-side Action Flow (a Data Action runs on the server, not the device). Scroll down to the Server Actions folder, and you'll see the equivalent Server Actions under the (System) reference, those you will be able to drag to your Action Flow.

If you don't see the actions you need, you may need to go to the "Manage Dependencies..." popup and add those Server Actions from (System).

I did not find what I need in Server Action Folderthen I want to add Server Actions in Manage

 Dependecies. How to add it?


By default (sometimes) Service Studio will filter your Dependencies to only show what you're using or modifying. In your case, check your 'Public elements' filter (highlighted red in the screenshot):

HI Jorge,


Jorge Martins wrote:

Arvin Fairuz wrote:

Jorge Martins wrote:

  • have a single Aggregate for all rooms on all floors and process the result and split it in multiple lists using your own logic.

Typically the first approach is discouraged, and Service Studio will likely warn you, as Aggregates (even if accessing LocalStorage) have a relevant impact on mobile App performance.


can you give me a simple example for the logic of the 2nd option ? because my problem is on the logical implementation.

Here are instructions, and how I would organize the action flow:

  1. Create a new RoomsByFloor structure that has a Floor attribute of type Integer that will hold the floor number, and a Rooms attribute of type List of Text.
  2. Add a Local Variable Floors on your screen of type List of RoomsByFloor.
  3. Add another Local Variable RoomsByFloor of type RoomsByFloor.
  4. On your Preparation, create a GetFloorRooms Aggregate that returns all FloorRoom records, ordered by FloorRoom.Lantai and then by FloorRoom.Rom.
  5. Use the Cycle tool to iterate GetFloorRooms.List.
  6. Add an If tool on the cycle with Condition RoomsByFloor.Floor = GetFloorRooms.List.Current.FloorRoom.Lantai and set its Label to Same Floor?
  7. On the True branch of the If tool, add a ListAppend Action, name it AppendRoom and on the List Input Parameter pass it the RoomsByFloor.Rooms, and on the Element Input Parameter pass it GetFloorRooms.List.Current.FloorRoom.Rom
  8. Connect the ListAppend Action back to the Cycle tool.
  9. On the False branch of the Same Floor? If tool, add another If tool with Condition RoomsByFloor.Floor = "" and set its label to First Floor?
  10. On the False branch of the First Floor? If tool add a ListAppend Action, name it AppendFloor and on the List Input Parameter pass it the Floors, and on the Element Input Parameter pass it RoomsByFloor.
  11. After the AppendFloor Action add a ListClear Action, name it ClearRooms and on the List Input Parameter pass the RoomsByFloor.Rooms.
  12. After the ClearRooms Action add an Assign tool, set its Label to Assign Floor and assign to RoomsByFloor.Floor the value of GetFloorRooms.List.Current.FloorRoom.Lantai.
  13. Connect the Assign tool to the AppendRoom action added in 7.
  14. Connect the True branch of the First Floor? If tool (defined in 9.) to the Assign Floor tool defined in 12.

In the end you will have a list of "floors" (RoomsByFloor), and each "floor" will have a list of rooms on that floor.

You should be able to come up with this short algorithm on your own, logical reasoning is an essential skill for any developer that I encourage you to exercise more (you can find lots of exercises online on algorithms and problem solving)


I have followed your direction, how can I take the list room based on floor value?

you can see my .oml

Thanks,

Imas Deny 

Hi Imas,

Following you can find several remarks about your module (and my previous instructions)...

In my instructions, the following step is wrong, assuming that RoomsByFloor structure defined its Floor attribute as an Integer 

  1. On the False branch of the Same Floor? If tool, add another If tool with Condition RoomsByFloor.Floor = "" and set its label to First Floor?

It should read something like:

  1. On the False branch of the Same Floor? If tool, add another If tool with Condition RoomsByFloor.Floor = 0 and set its label to First Floor?

Careful, if your floors start from 0 you should come up with a default value for RoomsByFloor.Floor that cannot occur in your data set. If it makes sense for the Floor attribute to be Text then change it on the RoomsByFloor structure and keep the Condition above as is.

That being said, you have several problems in your module, mostly because you skipped/adapted steps from those instructions as I didn't know where you'd want to implement that logic:

  • You can make Floors an Output Parameter directly.
  • OutRoomsByFloor isn't needed, you can delete it.
  • The List input parameter of the ClearRooms action should be RoomsByFloor.
  • On your screen, you need two nested Lists:
    • the outer list should iterate over DataAction1.Floors (gives you access to the floor number: DataAction1.Floors.Current.Floor)
    • the inner list should iterate over DataAction1.Floors.Current.Rooms (gives you access to the room number: DataAction1.Floors.Current.Rooms.Current)

Hope this helps

HI Jorge,


Jorge Martins wrote:

Hi Imas,

Following you can find several remarks about your module (and my previous instructions)...

In my instructions, the following step is wrong, assuming that RoomsByFloor structure defined its Floor attribute as an Integer 

  1. On the False branch of the Same Floor? If tool, add another If tool with Condition RoomsByFloor.Floor = "" and set its label to First Floor?

It should read something like:

  1. On the False branch of the Same Floor? If tool, add another If tool with Condition RoomsByFloor.Floor = 0 and set its label to First Floor?

Careful, if your floors start from 0 you should come up with a default value for RoomsByFloor.Floor that cannot occur in your data set. If it makes sense for the Floor attribute to be Text then change it on the RoomsByFloor structure and keep the Condition above as is.

That being said, you have several problems in your module, mostly because you skipped/adapted steps from those instructions as I didn't know where you'd want to implement that logic:

  • You can make Floors an Output Parameter directly.
  • OutRoomsByFloor isn't needed, you can delete it.
  • The List input parameter of the ClearRooms action should be RoomsByFloor.
  • On your screen, you need two nested Lists:
    • the outer list should iterate over DataAction1.Floors (gives you access to the floor number: DataAction1.Floors.Current.Floor)
    • the inner list should iterate over DataAction1.Floors.Current.Rooms (gives you access to the room number: DataAction1.Floors.Current.Rooms.Current)

Hope this helps

thanks your reply before,
simple question, how to show the room data in list by floor, like image below :


Thanks,

Imas Deny 


Hi Imas,

In OutSystems you use Expressions to evaluate and display dynamic data.

  • On your screen, you need two nested Lists:
    • the outer list should iterate over DataAction1.Floors (gives you access to the floor number: DataAction1.Floors.Current.Floor)

I highlighted how you can get the floor number... you just need to have an Expression with that value before you display the list of rooms.