Hi, i need to make validation for new time logs during user add them, the main purpose is to black user option for adding more than 8h total logs for day, all logs above 8h total should be marked as “overtime”, someone have different idea than using Action Menu Item :)?
You can also use ShotgunEvents (GitHub - shotgunsoftware/shotgunEvents: ShotGrid event processing framework.) to track any new event created for the Timelog entity. If a new timelog entry is created, it can calculate the total duration for the logs and if it exceeds 8h you can delete that newly created timelog entry but one exception here is that the user will still be able to create timelog entries and later the validation part will take place.
Another solution that I can think of is that you can provide the users who update the timelog for Tasks with a standalone (Qt)desktop application. In this manner you can set the validations you want to before creating a new entry for Timelog entity in shotgrid.
Hope this was helpful.
I took this into consideration, but from what I understand, webhooks only work after a new time log entry is created and I need to check this in advance, plus I prefer to display information about how much time the user has left
I thingk that it will be very problematic to automatically remove some entries, without informing user about that, even if I use email or slack to inform about that Maybe AMI is best solution
Apologies for this. I guess I misunderstood the question. So for each task you want timelogs of total 8h and any timelog added afer that should be considered as overtime? If this is the use case you can stil use ShotgunEvents. One way is that you create a new column called as Timelog Type with type as list of just two values (Regular and Overtime) within the global Timelog page. After that whenever a user creates a new timelog, the triggered event can be analyzed using ShotgunEvents. Once the event is generated it can do the following operations:
Check the total duration for all the timelogs for that task including the duration of new timelog.
If the total duration is less than 8h when the new timelog is added, you can update the value for the new column to be Regular for the new timelog entry that is created.
If the duration is more than 8h when the new timelog is added, you can update the value for the new column to be Overtime for the new timelog entry that is created.
This will also give a summary of the total hours the user has spend on the task as Normal working hours and hours that has been spent as overtime. Also there is no requriement to delete any timelog values in this.
Actually, the result you want is possible by using new functionality in ShotGrid.
What you can do to have more control over Timelog creation is to take over the “Create Timelog” button.
What you would do, is create an AMI and set the
Configure Menu Options to
Override "Add Entity" button on Entity Pages.
This overrides the native ShotGrid Dialog that is used for creating a record and will defer this to your AMI.
You could either use a Python script to create a dialog to create Timelogs, open an application to it or use a web server to catch this and create a web ui to do exactly what you want to do and display any validation you want to do.
I thought about something similar to what you describe, it could be ok. Thanks!
It’s looks like something I look for for whole time! Thanks! Need to test that