Announcement

Collapse
No announcement yet.

Creating a custom function to be used with entities

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

  • Creating a custom function to be used with entities

    Hi all

    As it's my first post, just let me send my congrats to the EspoCRM development team; I have worked several years with SuiteCRM, and now than I have found EspoCRM, I just needed five minutes to decide to move my develop to EspoCRM. Great job...

    I'm trying to create a "custom function"; followed all instructions in "Defining new functions for Formula", but I always getting a BAD SERVER RESPONSE message when trying to save the record.

    I can't find any info about the possible error in EspoCRM log neither Apache logs ... Any suggestion?

    The code use is as follow :

    FILE: custom/Espo/Custom/Core/Formula/Functions/UtilsGroup/EUIDlongType.php

    <?php
    namespace Espo\Custom\Core\Formula\Functions\UtilsGroup;

    use \Espo\Core\Exceptions\Error;

    class EUIDlongType extends \Espo\Core\Formula\Functions\Base
    {
    public static function process(\StdClass $item)
    {
    if(!property_exists($item, 'value') || !is_array($item->value) || (count($item->value) < 1))
    throw new Error();

    $prefix = $this->evaluate($item->value[0]);

    return $prefix . number_format(microtime(TRUE),2,'','');
    }
    }
    ?>


    FILE: custom/Espo/Custom/Resources/metadata/app/formula.json

    {
    "functionList":
    [
    "__APPEND__",
    {
    "name": "utils\\EUIDlongType",
    "insertText": "utils\\EUIDlong(PREFIX)"
    }
    ],
    "functionClassNameMap":
    {
    "utils\\EUIDlong": "\\Espo\\Custom\\Core\\Formula\\Functions\\UtilsGr oup\\EUIDlongType"
    }
    }


    and the call inside "Formulas" : euid = utils\EUIDlong('CTTO-')

  • #2
    Remove the static

    Comment


    • #3
      Nope .... still failing

      As a test, I have just copy&paste one of the "official" code inside 'application/Espo/Core/Formula/Functions/NumberGroup' and got same result ... BAD SERVER RESPONSE

      Comment


      • #4
        OK, SOLVED ... Thanks Andorxor ...

        Comment

        Working...
        X