Checking for a week number in a workflow expression - Printable Version +- CoreBOSBB (https://discussions.corebos.org) +-- Forum: Support (https://discussions.corebos.org/forumdisplay.php?fid=17) +--- Forum: Administrator Support (https://discussions.corebos.org/forumdisplay.php?fid=8) +--- Thread: Checking for a week number in a workflow expression (/showthread.php?tid=999) Pages:
1
2
|
Checking for a week number in a workflow expression - Guido1982 - 03-30-2018 I have the following setup:
Now I'd like to setup a workflow that runs once a week. The purpose of this workflow is to:
If those conditions are met, an e-mail should be sent out. Can I do this through the workflow expression engine and if so, does anyone have some pointers on the syntax? RE: Checking for a week number in a workflow expression - joebordes - 04-01-2018 This condition should work: week_field smaller than (workflow expression) format_date(get_date('today'),'W') RE: Checking for a week number in a workflow expression - Guido1982 - 04-02-2018 Thanks! So basically format_date(get_date('today'),'W') outputs the current week no.? RE: Checking for a week number in a workflow expression - joebordes - 04-02-2018 correct! you can use any valid PHP date modifier RE: Checking for a week number in a workflow expression - Guido1982 - 04-04-2018 Would this also work in reports by the way? EDIT: I have a small problem in the week comparison field. It doesn't show me the 'smaller than' option in the dropdown. So now I have something like 'productionweek is if so_productionweek < format_date(get_date('today'),'W') end'. Don't know if that will work. SECOND EDIT: Changed that to: if so_productionweek < format_date(get_date('today'),'W') true else false end. Hopefully the workflow expression now returns true or false, making the condition functional. THIRD EDIT: OK, my second edit broke the application, so no dice there. RE: Checking for a week number in a workflow expression - joebordes - 04-04-2018 What type is the so_productionweek field? You can use the evalwf.php script to evaluate the workflow conditions against different records and see if it will work or not. RE: Checking for a week number in a workflow expression - Guido1982 - 04-04-2018 UI type 15, picklist. Thanks! Will check this. RE: Checking for a week number in a workflow expression - Guido1982 - 04-04-2018 I have the weirdest thing here: I created some workflow expressions, none of them worked. I created this one just for testing: Code: if salesorder_no == 'ORD1800484' then 'A' else 'B' end Code: SELECT vtiger_salesorder.salesorderid FROM vtiger_salesorder INNER JOIN vtiger_crmentity ON vtiger_salesorder.salesorderid = vtiger_crmentity.crmid WHERE vtiger_crmentity.deleted=0 AND ( (( vtiger_salesorder.so_productionyear = '2018') and ( vtiger_salesorder.so_productionyear = 'B') )) AND vtiger_salesorder.salesorderid > 0 Hmm, it looks like the workflow is working when I test it. The eval script doesn't do a live check maybe? By the way, I used a little trick to check the week, since 'smaller then' was not available: I used the field 'so_productionyear' for comparison to check against (using 'is'). Then I used: Code: if so_productionweek < format_date(get_date('today'),'W') then so_productionyear else '1000' end RE: Checking for a week number in a workflow expression - joebordes - 04-04-2018 If you get the SQL I understand that you are creating a scheduled workflow. Scheduled workflows do not support expressions because they would need to be translated to SQL which is VERY complex. In scheduled workflows only basic conditional operations that can be directly translated to SQL are supported. I would suggest you create a numeric custom field and fill it in with the value in the picklist with an update field workflow and then create the scheduled workflow based on the numeric field. RE: Checking for a week number in a workflow expression - Guido1982 - 04-05-2018 Ah, I didn't know that. Could I hide the field that the first workflow task auto-fills? Or are hidden fields excluded from workflow comparison? |