I have an app for task Management where you can log tasks, start time, end time, comments, status, etc. I want to add a Bot that automatically closes the last “In progress” task (meaning, endTime is blank) when a new one is created.
Here is a simplified version of the app: TaskManager - AppSheet
So far I have only been able to create an Action “End Task” that works and I’m trying to make another one “End Last Task” that will close the last created one. I’m having 2 difficulties:
Solved! Go to Solution.
I personally do not like to use _RowNumber. I feel there is no guarantee that the rows will be in a known order - especially if the data comes from a database where a db view or indexing has modified the order.
This is what I would do.
In your use case you have just created a new Task row and want to “complete” the previous one. If we can assume that all previous task rows for this User have already been completed then there should only be two rows where ISBLANK([endTime]).
Then there are two ways to differentiate those rows:
So I would use an expression like this:
SELECT(Tasks[id], AND(USEREMAIL() = [_THISROW].[User],
ISBLANK([endTime]),
[id] <> [_THISROW].[id]))
User | Count |
---|---|
15 | |
12 | |
9 | |
8 | |
4 |