Announcement

Collapse
No announcement yet.

URL cleaning function

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

  • URL cleaning function

    anyone spot what I'm missing with this function?...

    This works:

    Code:
    jitsiMeeting = string\replace(string\concatenate('meet.jit.si/', assignedUserName, '-', contactsNames, '-', leadsNames, '-', parentType, '-', parentName ), ' ', '-');
    But this doesn't:

    Code:
    jitsiMeeting = string\replace(string\concatenate('meet.jit.si/', assignedUserName, '-', contactsNames, '-', leadsNames, '-', parentType, '-', parentName ), ' '||'&'||':'||'/'||'--'||'---'||'----'||'-----'||'------', '-');
    Guessing you can see what's it's intended to do.

    Following the docs: https://docs.espocrm.com/administration/formula/

  • #2
    As far as I know, you canĀ“t use formula in this kind of nested form "string\replace" and inside this "string\concatenate". I would concatenate to a new field (that you do not have to put into the layout) and use this field as value in the string\replace. In other words: two steps.

    Comment


    • #3
      Thanks shalmaxb

      This is what I've ended up with, not pretty, but gets me moving on with the day - and maybe others will find useful for creating a "Jitsi Meeting" URL on Calls & Meetings:

      Code:
      $meetingID = number\randomInt([001, 999]);
      
      ifThen(
      parentName,
      $parentName = string\concatenate('-', parentName, '-'),
      );
      
      $slug = string\concatenate(
      assignedUserName,
      '-',
      parentType,
      $parentName,
      $meetingID,
      );
      
      $cleanURL = string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      string\replace(
      $slug,
      ' ',
      '-'
      ),
      '/',
      '-'
      ),
      '|',
      '-'
      ),
      '(',
      '-'
      ),
      ')',
      '-'
      ),
      '&',
      '-'
      ),
      ';',
      '-'
      ),
      '.',
      '-'
      ),
      ',',
      '-'
      ),
      ';',
      '-'
      ),
      ':',
      '-'
      ),
      '@',
      '-'
      ),
      '-----',
      '-'
      ),
      '-----',
      '-'
      ),
      '----',
      '-'
      ),
      '---',
      '-'
      ),
      '--',
      '-'
      );
      
      jitsiMeeting = string\concatenate('meet.jit.si/', $cleanURL);

      Comment


      • espcrm
        espcrm commented
        Editing a comment
        This format layout look prettier, despite it long vertical length.

    • #4
      This doesn't seem to limit the random number to 3 digits, but maybe I'm missing something about how that function works?
      Code:
      $meetingID = number\randomInt([001, 999]);

      Comment


      • #5
        A bit strange, does not work with varchar neither integer field, but works with number field and outputs this: Fieldname: Random Number value: 1366561402839493105
        I guess, that is not as desired, but did not get it to work otherwise.

        Comment


        • marcusquinn
          marcusquinn commented
          Editing a comment
          Odd, either a bud or misunderstanding of the documentation I think.

          The full function above is still handy for generating meet.jit.si links for anyone that wants to add a Jitsi Meeting field to their Calls & Meetings, kinda handy, free and E2E encryption secure as I understand.
      Working...
      X