18
Views
3
Comments
Solved
Data action for collecting data for a schedule does not function correctly
Application Type
Traditional Web

Context:

The purpose of the application is to manage employee schedules for a given week. The user can view schedules in a table format and click on individual cells representing a day in the week for each employee. If the cell already contains a schedule, the popup opens with the existing data so the user can edit it. If the cell is empty, the popup opens with an empty form to create a new schedule entry for that employee on the selected day.

I now have an action which retrieves all employees and Creates the desired structured output.


The issue here is that i now disabled the listclear elements but when i use the debugger to retrieve the data i notice that for every employee it shows all the daylistdata and for all the daylist data it shows all the schedule list data even when it is not for that employee. Hence the listClear elements.


But if i do it like this i get no data returned at all. Below is my OML. If needed more info please reply.


ScheduleApp.oml
2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Hi @Piet Pieper ,

the reason you are not getting data out, is that you are using Assigns to fill lists in your output with local lists, and then clear the local list.

Assign statements work by value for non-list variables, but lists are tricky.  Sometimes, but not always, the assign is by reference.  This is very confusing.

I try to avoid assigning one list to another, but use ListAppendAll instead.

I changed your code a bit, and I also added a new testscreen to your oml to demonstrate this.

Apart from solving this, I think you are setting yourself up for difficulties if you export it like this, with a list of days instead of day 1 to day 7, you'll need a lot of indexing on your frontend to get this into a table (ie rows turned into columns of the table) and that is a very fragile solution.

Also something to watch, is not having too many loops hitting the database.  Here you have 3 levels, so let's say 10 employees X 7 days  = 1 + 10 + 70 = 81 database calls.  

Dorine

ScheduleApp.oml
UserImage.jpg
Piet Pieper
Solution

Hi @Dorine Boudry


Thanks a lot for your help and response.

What would be the solution to fix this performancewise? 


i would like to hear from you!

2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Hi @Piet Pieper ,

the reason you are not getting data out, is that you are using Assigns to fill lists in your output with local lists, and then clear the local list.

Assign statements work by value for non-list variables, but lists are tricky.  Sometimes, but not always, the assign is by reference.  This is very confusing.

I try to avoid assigning one list to another, but use ListAppendAll instead.

I changed your code a bit, and I also added a new testscreen to your oml to demonstrate this.

Apart from solving this, I think you are setting yourself up for difficulties if you export it like this, with a list of days instead of day 1 to day 7, you'll need a lot of indexing on your frontend to get this into a table (ie rows turned into columns of the table) and that is a very fragile solution.

Also something to watch, is not having too many loops hitting the database.  Here you have 3 levels, so let's say 10 employees X 7 days  = 1 + 10 + 70 = 81 database calls.  

Dorine

ScheduleApp.oml
UserImage.jpg
Piet Pieper
Solution

Hi @Dorine Boudry


Thanks a lot for your help and response.

What would be the solution to fix this performancewise? 


i would like to hear from you!

UserImage.jpg
Piet Pieper

@Dorine Boudry I still can not figure out how to get the data into my schedule, i can't use index because some dates have no data on them.

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