12
Views
2
Comments
Solved
[OutSystems Data Grid] Automatically generate Start/End times based on sorting & duration
outsystems-data-grid
Reactive icon
Forge asset by OutSystems
Application Type
Reactive

Hi everyone,

I might have a slightly tricky question, but I’m hoping that some of you can provide me with tips or solutions! 😊

Here’s the current scenario:

  • I have a Data Grid where rows are sorted, when using the safe button - using a JavaScript based on the columns Date (primary) and Date_Num (secondary). This allows me to define the order of rows for each date, e.g. rows are sorted in the order 1, 2, 3, 4, … for a given day.
  • Additionally, the grid has the columns Start, End, and Duration. Duration is a dropdown where users can select values like 20, 25, 30 (minutes).

What I’d like to achieve:

  • Based on the sorting (Date → Date_Num) and the selected Duration, I want to automatically generate the Start and End times for each row.
  • The times should begin at 10:00 AM for the first row of each date. The End time of a row should be calculated by adding the Duration to the Start time, and the Start time of the following row should match the End time of the previous row. This process should repeat for all rows of the same date, until a new Date is encountered.

Example:

  • Row 1: Date = 2025-01-01, Date_Num = 1, Start = 10:00, Duration = 20 → End = 10:20
  • Row 2: Date = 2025-01-01, Date_Num = 2, Start = 10:20, Duration = 30 → End = 10:50
  • Row 3: Date = 2025-01-01, Date_Num = 3, Start = 10:50, Duration = 20 → End = 11:10
  • If the Date changes, the Start time resets to 10:00 for the new Date.

Question:

  • How can I implement this? using JavaScript ? Is there an efficient way to loop through the rows, generate the times based on the algorithm described, and fill in the Start and End values automatically?

I attached a sample oml. Any insights, tips, or examples would be greatly appreciated! Thanks! 😊

Best regards

AgendaSample.oml
UserImage.jpg
T S
Solution

I added in the saving workflow a new client action, which contains a javascript to generate the times:

2026-02-10 17-07-54
Uriel Henrique Lucas Gomes

Hi T S, have you tried using addHours to update your entire grid when generating a new row?

Working in datetime

you have functions to add hours, minutes and seconds. You just need to use all three.

AddSeconds(AddMinutes(AddHours(Date1,Hour(Date2)),Minute(Date2)),Second(Date2)))

UserImage.jpg
T S
Solution

I added in the saving workflow a new client action, which contains a javascript to generate the times:

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