Round robin script for assigning leads

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • office
    Member
    • Jun 2025
    • 42

    #1

    Round robin script for assigning leads

    Doesnt work:
    Do you have any idea why?

    [2025-07-17 12:57:26] CRITICAL: (500) Formula script error. Bad function name `MOD:`. :: POST /Lead :: /var/www/html/application/Espo/Core/Record/Formula/Processor.php(94)


    ifThen( entity\isNew() && !entity\attribute('assignedUserId'), ( $teamId = '6878c9e44b0e2379b'; $userIds = record\findRelatedMany('Team', $teamId, 'users', null, 'id', 'asc', 'isActive', true); ifThen( array\length($userIds) > 0, ( $currentCursor = number\parseInt(string\concatenate(env\userAttribu te('preferences', 'rrLeadCursor'), '')); $currentCursor = ifThenElse($currentCursor, $currentCursor, 0); $nextIndex = MOD: ($currentCursor, array\length($userIds)); $assignedUserId = array\at($userIds, $nextIndex); entity\setAttribute('assignedUserId', $assignedUserId); entity\addLinkMultipleId('teams', $teamId); $newCursor = ADD: ($currentCursor, 1); env\setUserAttribute('preferences', 'rrLeadCursor', string\concatenate($newCursor, '')); ) ); ) );
    Last edited by office; Yesterday, 01:01 PM.
  • lazovic
    Super Moderator
    • Jan 2022
    • 1109

    #2
    Hi office,

    Complex expressions (MOD, ADD) cannot be used in the formula script in EspoCRM. You can see the list of available functions for the formula script here: https://docs.espocrm.com/administrat...mula-functions.
    Last edited by lazovic; Yesterday, 01:07 PM.

    Comment

    • victor
      Active Community Member
      • Aug 2022
      • 952

      #3
      Most likely, you were given a formula or code that doesn't exist. It could have been an unscrupulous developer who didn't test the functionality before passing it on to you, or it could have been an incorrect response from the AI.

      Comment

      Working...