Announcement

Collapse
No announcement yet.

editing strings with formula

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

  • editing strings with formula

    hello
    We want to format the phone number field in the contacts with formula.
    All special characters (-/\()_ ) are to be deleted.
    Is there a possibility in formula?
    peter

  • #2
    hello,
    it could be possible only if you develop own function for formula

    Comment


    • #3
      Hi,

      I have write a custom formula : who remove a non numeric char from a string.
      https://www.espocrm.com/documentatio...on-in-formula/

      But 3 think :
      1) error in the documentation see below formula.json
      2) with this, I loose all other function .. where I am wrong ?
      3) why we don't put formula in custom directory ?
      Regards



      PHP Code:
      <?php

      /************************************************************************

       * This file is part of EspoCRM. (I have remove for facility for forum read)

       ************************************************************************/


      namespace Espo\Core\Formula\Functions\StringGroup;

      use 
      \Espo\Core\Exceptions\Error;

      class 
      NumericVal extends \Espo\Core\Formula\Functions\Base

      {

          public function 
      process(\StdClass $item)

          {

              if (!
      property_exists($item'value')) {

                  return 
      '';

              }

              if (!
      is_array($item->value)) {

                  throw new 
      Error();

              }

              if (
      count($item->value) < 1) {

                  throw new 
      Error();

              }

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

              if (!
      is_string($value)) {

                  
      $value strval($value);

              }

              return 
      preg_replace("/[^0-9]/"""$value);

          }

      }

      PHP Code:
      {
          
      "functionList": [
              {
                  
      "name""string\\numericVal",
                  
      "insertText""string\\numericVal(STRING)"
              
      }
          ]   <------ 
      this is missing in documentation

      Comment


      • #4
        Hello,
        as I can see ']' exists in the guide
        with "__APPEND__" (it is in the documentation as well) the list wont be overwritten
        in the article formula definition is in custom folder.
        So sorry, I can't understand the problem

        Comment

        Working...
        X