Announcement

Collapse
No announcement yet.

Can use the PHP function empty() in scripts?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #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) {}

    Comment


    • murugappan
      murugappan commented
      Editing a comment
      yuri thank you for the update.

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

    PHP Code:

     
    {{#if field}} field is not empty {{else}} field is empty {{/if}} 

    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...
X