A workflow that assigns invoices to the current user after saving - Printable Version +- CoreBOSBB (https://discussions.corebos.org) +-- Forum: Development (https://discussions.corebos.org/forumdisplay.php?fid=18) +--- Forum: coreBOS Development (https://discussions.corebos.org/forumdisplay.php?fid=4) +--- Thread: A workflow that assigns invoices to the current user after saving (/showthread.php?tid=518) |
A workflow that assigns invoices to the current user after saving - Guido1982 - 12-06-2016 I have this workflow custom function in place: PHP Code: function updateInvoiceAssignedTo($entity) { But not able to test it, would the getting of the current user ID work by getting it from the session? RE: A workflow that assigns invoices to the current user after saving - joebordes - 12-06-2016 Workflow custom functions are executed immediately on the save event and at that moment the $current_user variable contains the user launching the save. Although I think the code you have is correct and should work correctly because the session variable must also contain the current user id, you can use the $current_user object. $current_user->id and even just the session variable directly, there is no need to go through the trouble of creating the user object and the extra database queries $params = array($_SESSION['authenticated_user_id'], $invoice_crm_id); I'd say it will work. RE: A workflow that assigns invoices to the current user after saving - Guido1982 - 12-06-2016 Weird, that's also not working. I can't seem to default the invoice to the user that creates it. Must be doing something wrong, but what... |