Can use the PHP function empty() in scripts?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • murugappan
    Active Community Member
    • Aug 2017
    • 467

    Can use the PHP function empty() in scripts?

    Hi,

    There seems to be 2 types of scripts in Espocrm. One is the type defined in Entity formula and the other is in workflows. If i am not mistaken the workflow version allows standard PHP code for conditional whereas the entity version does not. In both, I want to use PHP empty() function which I do not see in the documentation. My question is: can use the following in these scripts for conditions?

    (1) If (empty()) {do something}
    (2) if (field) to test for true value. Example "If (date) do something..."
    (3) if (!date) to test not true condition

    Please advise.
  • yuri
    Member
    • Mar 2014
    • 8443

    #2
    Hi,

    In workflows we can use either formula or the UI. PHP is not supported (and it's for good).

    BTW, the empty function in PHP is considered by modern standards as not advisable to use.

    Use:
    Code:
    if (field) {}
    Code:
    if (!field) {}
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment


    • murugappan
      murugappan commented
      Editing a comment
      yuri thank you for the update.
  • item
    Active Community Member
    • Mar 2017
    • 1476

    #3
    HI,
    you can to use in template something so :

    PHP Code:
    
     {{#if field}} field is not empty {{else}} field is empty {{/if}} 
    
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment


    • murugappan
      murugappan commented
      Editing a comment
      item thank you for the additional information. Have not started ysing php in templates yet. Information is handy as we may soon started using it.
Working...