Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:extensions:workflowdesigner:custom-functions [2014/10/15 18:55]
swarnat
en:extensions:workflowdesigner:custom-functions [2021/09/24 14:15]
swarnat removed
Line 1: Line 1:
 ====== Custom functions ====== ====== Custom functions ======
  
-<WRAP important round> +[[https://manuals.redoo-networks.com/​wiki/​manuals/​view/​Workflow%20Designer/​Components/custom%20Functions/]]
-==== Important ==== +
-**This Page describe a feature, which require PHP development skills.** +
-If you use this feature in a wrong way, you could crash the Workflow! +
-</​WRAP>​ +
- +
-Lots of Workflow Tasks in the Designer could use custom functions. +
- +
-You recognize the option to use this functions, if you have an green border around a textfield and a special icon () next to the textbox. +
- +
-Almost all such fields have special hints about this function. (for example, what value you have to return) +
- +
-These scripts are default PHP Scripts with limited functions. All whitelisted PHP functions have the same arguments, like the original one. +
-**Each custom function have to return a value with the "​return"​statement.** +
- +
-You could use the following PHP functions:​ +
- +
-  * md5, rand, implode, substr, explode, microtime, date, time, sha1, hash, intval, floatval, floor, ceil, foreach +
-  * all functions, started with "​str"​ (strpos, str_pad, str_replace,​ ...) +
- +
- +
-==== Additional functions ==== +
- +
-There are existing some special functions you could use to do vtiger related special tasks. +
-Also you could create your own functions. [[en:​extensions:​workflowdesigner:​customization|Read here]] +
- +
-Read the full documentation here: [[https://support.stefanwarnat.de/custom-functions/]] +
- +
-==== custom function Examples ==== +
- +
-This example is only written to demonstrate the functions and could be done better. +
-<code php> +
-$var1 = "​864"​."​0";​ +
-$var1 = $var1.(0 + intval($vtiger_purchaseorder)).intval($vtiger_purchaseorder);​ +
-$var2 = 1 + (2 * 5) - 8; +
-$var1 = substr($var1,​ 0, 5); +
-if($vtiger_purchaseorder == "​1"​) { +
-   $add = intval($var1) * $var2; +
-   ​return time() + $add; +
-} else { +
-   $add = intval($var1) * intval($vtiger_purchaseorder);​ +
-   ​return time() + $add; +
-+
-</​code>​ +
- +
-These function could be used inside the delay task to wait one day, or the amount of days in the Purchase Order Field of an invoice. +
- +
-**Here you could see one limitation of my implementation:​** +
- +
-If you want use mathematical operations, you have to use parentheses to become the correct result, because the system ignore basic mathematical rules. +
- +
-==== Other examples ==== +
- +
-Wait until same day next month +
-<code php> +
-return date("​Y-m-d",​ strtotime("​+1 month"​));​ +
-</​code>​ +
- +
-Wait 5 days +
-<code php> +
-$days = 5; +
-$date = strtotime($datefield);​ +
-return date("​Y-m-d",​ $date + (86400 * $days)) +
-</​code>​+