Hi all, I'm not very experienced and have come up an issue I need some bigger brains to help with if possible.
We are using PK4 for Time Tracking, which results in us using a Project Object that hold info on a Project and TT Details, which holds the individual time submissions, that relate to a Project.
During the Projects lifecycle it goes through several defined stages, from Start-up, Discovery, Build, Test, Launch.
We are trying to sum the hours for each stage on a project to see if it matches the forecast e.g. we forecast 20 hours for Build and the Actual hours submitted for that Project on the Build stage (worktype) is 15
We have been supported and have a APEX Trigger that does this successfully, when the Time submission is approved, it adds the value of that submission to a field in the Project called Actual Hours for Build.
The users weren't maintaining the date so we have added some Validation rules into the Project object and now when the Apex Trigger runs it stops if a project associated with one of the time submissions has any element which does has a validation error. eg validation rule - If lastupdate date is < today()-30 "You need to update the status for the project"
I am not experienced and have very limited resource so have to find a way thorough this somehow.
I was thinking of trying to find a way to deactivate all the validation rules off at the start of the Apex trigger and then back on... but no idea if that is possible.
I have tried to set-up a Flow, one for each stage, that is triggered on the Time submission approval changing, that would then add it to the Field in the Project, but I can't get it to work.
So I am starting to hit a dead end to understand what is even possible or the direction to take to resolve the issue.
Any pointers would be greatly appreciated
approval status changes it add the
Sushil Kumar (UKG) Forum Ambassador
Couple of things possible 1. Modify validation rule so it only runs for certain field changes. 2. Add validation rule on child object to prevent creation of child records when project status is invalid. This will prevent nasty apex error. 3. Regarding your question about deactivating validation rules during time submissions, if time submissions was In Apex and also validation was written in apex, then there is way to bypass validation using static variables in code.