I’m working on an object type called “Projects” where each object represents a project. For each project, we want to display and manage a Gantt chart-style planning, showing key events with start and end dates.
To achieve this, I created a second object type called “Events”, where each object represents a planning event with the following properties:
UUID (primary key)
End timestamp
Start timestamp
Event name
In the Projects object view (workshop), users can add events through a table action form that triggers an action called “Create Event”. This allows them to manually input (or paste) multiple events along with their start and end dates.
The issue:
Some event types (based on their name) should have their end timestamp automatically calculated, relative to the start date (e.g., “X + 3 weekends”). But others should have their end date manually set by the user.
The current limitation is that the form only allows defining a single static value for the end date column, which is applied to all rows equally. This doesn’t support conditional logic per row based on the event name.
My question:
Is there a way to implement per-row dynamic logic in a table action form (or another component), so that:
For certain event names, the end date is automatically calculated based on the start date (e.g., start date + X days or weekends)?
For others, users can manually input the end date?
Any suggestions for how to approach this within the ontology framework (via calculated properties, expressions, form config, or custom code) would be greatly appreciated.
Hi @gdf might be a bit hacky way but I think this could work.
add an additional property „duration“ to your action type which is generally disabled but visible (can be enabled if you want to give users the option to define the duration instead the end date)
The default value (and enabledness) is controlled through overrides based on the event name.
If an event name with pre-defined duration is selected, the override sets the default value and overrides the end date to disabled and default value null
You calculate the resulting end date within your action type
If the event name has no pre-defined duration, you just leave the duration null and have the end date enabled for input (or optionally have the duration enabled as well and if that is filled, the end date is automatically disabled and nulled for calculation in action type)
Small downside would be that you can not show the user the end date within the action table, but at least this should work.
In case the action table is not a hard requirement you could build a simple form-esque layout where you can do all the calculations through variables. But then the submission would always be event by event - not a list users fill at once.
Building off of @Phil-M’s response, we do exactly this and use a TypeScript v1 function to back the relevant Action Type for a similar “event” Object Type that needs an event_start Timestamp property and an event_end Timestamp property.
I think the pseudocode you’re looking to implement may look something like this:
Inputs:
Required
Event object
start_time
Optional
Duration (Integer)
Unit (string) i.e., minutes, hours, days, weeks, etc.
Logic:
If eventObject.title === EXPECTED_VALUE_FOR_AUTO_THREE_WEEKENDS
then eventObject.start = start_date; eventObject.end = start_date.plusWeeks(3)
Else
if Unit
if Unit === “minutes” then eventObject.end = start_time.plusMinutes(duration)
if Unit === “hours” then eventObject.end = start_time.plusHours(duration)
etc.
Essentially, TypeScript v1’s imported Timestamp class has built-in methods for incrementing and decrementing units of time based on a reference timestamp.
Your Event Object Type doesn’t need to have a duration property, but it may be needed as a parameter on the Action form (this is how we implemented ours).
Note that if you want to support this feature as an in-line edit, since it will end up being a function-backed action, the maximum number of objects in the Object Table widget in Workshop that can be edited in one “Submission” is 20.