Adding a variable to the workflow expression engine - 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: Adding a variable to the workflow expression engine (/showthread.php?tid=517) Pages:
1
2
|
Adding a variable to the workflow expression engine - Guido1982 - 12-06-2016 Since Business Maps use the workflow expression engine, I'd like to add a new expression. I need to make a business map that defaults the assigned to user to the current user when creating an Invoice from a SalesOrder. As far as I know, there is not expression to get the current user (ID). How would I add this? RE: Adding a variable to the workflow expression engine - joebordes - 12-06-2016 I did a quick test. By default the currect user is set in the assigned_to field. I converted a SO that was assigned to another user and when I arrive at the invoice the assigned_to field is set to my current user, not the one on the SO. I created a map to change the subject and the assigned_to field was still set to the current user, so no change there. I added a mapping to assign the Invoice to another user and that worked correctly also. So, I'd say that you already have the behavior you are asking for. In any case, the wiki says that you have access to the current user information using the "TEMPLATE" type: http://corebos.org/documentation/doku.php?id=en:adminmanual:businessmappings:mapping Code: When creating a new record you always have access to all the fields of the current user using the FIELD or TEMPLATE types. For example: this it the mapping I created: Code: <map> RE: Adding a variable to the workflow expression engine - Guido1982 - 12-06-2016 Hm, that's weird. In my install, the assigned user for the invoice defaults to the one on the SO it was created from... I tried: Code: <field> But that gave very weird results. Any way I can add the 'id' field to the expression? RE: Adding a variable to the workflow expression engine - Guido1982 - 12-06-2016 This is really weird. I tested in my own install. There also an invoice will default to the user the SO is assigned to. In the coreBOS demo, the new invoice defaults to the current user. I don't understand why... I even went as far as to set the $focus->column_fields['assigned_user_id'] in the editview.php of Invoices. But still no dice. I did find out that this only works for non-mandatory fields. RE: Adding a variable to the workflow expression engine - Guido1982 - 07-13-2018 I can confirm this is still not working as expected (July 2018 version) Converting from an SO to an invoice WILL default the assigned user to the current one as far as I've tested. But when I use the following business map to control duplicates: Code: <map> The invoice duplicate WILL default to another user, but not the current one, it defaults to a user that isn't even active. I also tried the above map with the EXPRESSION type. Then I tried: Code: <map> With and without the delimiter. That defaulted to a group. One where the current user is not associated with. RE: Adding a variable to the workflow expression engine - Guido1982 - 07-13-2018 OK, I dug around a little. When I log the $user variable in this line (https://github.com/tsolucio/corebos/blob/master/modules/com_vtiger_workflow/VTEntityCache.inc#L16), I get the current user object as expected. But when I log the $data variable at the end of that __construct function, I get an array with the entity returned with the wrong assigned_user_id. My user ID is 6, but I get: PHP Code: [account_id] => 3x504 I get 14 back. And just for the heck of it I logged: PHP Code: public function __construct($user, $id, $deleted = false, $queue = false) { RE: Adding a variable to the workflow expression engine - Guido1982 - 07-13-2018 I've come a BIG step closer to what is happening. It is because the difference in user ID versus webservice user id. The module users has a webservice ID of 19. No matter which approach I choose, the assigned user keeps getting set to user no. 19, because the business map doesn't take the webservice markup into account. I've given up. I'll just revert back to my hack to default the user to the current one when duplicating records. RE: Adding a variable to the workflow expression engine - joebordes - 07-14-2018 See if this helps: https://youtu.be/9-RlN6e31BQ RE: Adding a variable to the workflow expression engine - Guido1982 - 07-15-2018 Will do and get back to you Thanks for the great video. This thread has - during time - gotten polluted with a lot of messed info by me. First of all, the original question was wrong. Partly because at the time I was working on an old installation (which I'm trying to upgrade now), which may have caused some effects that the more recent versions long fixed. Secondly, the question should not have been: how do I assign a user on conversion. That is working like we wanted out of the box now, and we have a lot of options to alter that behaviour now. My main problem is (and this should have been the original question): how do I get the salesorders and invoices to ALWAYS default to the currently logged in user when duplicating. Say you have a salesorder that is assigned to user A. User B logs in and wants to duplicate this salesorder. I want to make sure that when user B hits the duplicate button and the new, to be created salesorder opens in the edit screen, that salesorder is by default assigned to user B. Not user A, who was the assigned to user in the original salesorder. To be clear: I don't want the user related to a record, I want the currently logged in user (which we would get by PHP Code: global $current_user->id RE: Adding a variable to the workflow expression engine - joebordes - 07-15-2018 Try with this little gem: Code: <field> |