I create a logic hook to update the current day name such as monday, Saturday etc. This logic hook is working well if i change any record in Bug module, but there are some workflows scheduled that change bug’s records, I am expecting that each record updated trigger teh logic hook. I realized that some time the process run because I am writing in suitcrm.log but the record is not updated with the day name field. also I realized that the system is not running the logic hook each time when the bug’s record is updated. as I mention before if I use the front end to update any record the logic hook run very well. I mean if I edit any bug and change any value the system update the dayname of the week.
attached the log wher you can se that the logic hook is runing some times, and an also eth code.
log martes means Tuesday this is the record modification exected.
as you can see i wrote teh same logic hook before_save and after_save as a test but the behaivor is teh same. Works well from teh front end. The workflow even though is updating teh record is not triggering the LH.
The logic hook is fine. There is no issue i think. The issue is in Workflow. Are you updating the DAY field in Workflow as well? If not then it will not be auto updated by the hook for all the records. Basically you need to explain your workflow here as well. So that i can get an idea about what is the issue.
There is no any workflow updating the field dia_c I have a cpuple of workflows that run twice a day updating Bug status field. My expectation is that the logic hook run after this event and update dia_c field. this field was created by me and is located in bug_cstm table into the database.
I believe that the issue is the order of the event before_save or after_save it is possible that when teh logic_hook is activated the record is not longer available. But I am not a high experience developer and I am not able to follow the event sequence.
I create a PHP program updating the day of the week directly in the data base table bug_cstm field dia_c.
This program is called each 12 hours using a shedule progam.
The solution works well but the audit process is not registering the change of this field, because I am firing the field from external process not governated by suiteCRM.
I would still like to know the details of your Workflow, because it makes a difference, Workflows can be triggered from quite different places, and it is not the same which module the workflow runs for, and which (other) module you’re changing the data in an action.
Logic: I need to know labor days in each bug, to do this I create two dates
Logic: I need to know how many hours a ticket has been open and assigned to any resource.
To do this I created tow fields “Activation date” and “inactivation date”.
There are two workflows that ask for those dates and compare with the actual date, the work flow update the bug status. for example, activation date is 14/02/2020 8:00 Am if the actual date is 14/02/2020 8:00am => activation date and < inactivation date the work flow will change the status from stop time to assigned.
below is the work flow.
I have other similar workflow that compare the inactivation time with the actual date and change the status from Assigned to stop and also change the activation and inactivation time for the follow day.
It’s possible that the issue of the hook not triggering from the Workflow is a product limitation. This is more complicated than it seems, integrating hooks and workflows, one has to run first, the other afterwards; whatever option the devs made would leave some people unhappy. And you can’t have a loop where workflows run hooks and hooks then run workflows…
So if I were you I would try to avoid all that.
Another thing: what do you need the day of week fields for? If it’s just for display, maybe you don’t need to set that in the database, you can do changes on the display views, to calculate the value just before showing, similar to this one.
Finally: since your activation/deactivation logic will end up being quite complex, and you seem to be ok with writing some PHP, why don’t you just forget about Workflows and make a custom scheduler to run your logic?
@prg I solved the issue with the mix of workflow and PHP schedule task.
I create a PHP program that update the name of the day each 6 hours. as well I create a workflow schedule also that verified teh day name, if teh day is saturday the next ativation date of teh bug is two days after now. it means on monday. The pnlu issue is that the name of teh day is not audited. To solve thsi Y add a log for teh PHP where write a record eact time thatany recors is update wit the name of the day.
I tested this in the weekend and worked well.
You are asking why I need to storage day name. This is the trigger of the work flow. To avoid workflow running each hour once the next activation date is updated the flag weekend is selected. On monday the workflow that activate bugs unselect the weekend flag.