Announcement

Collapse
No announcement yet.

Advanced pack, help with automation

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

  • Advanced pack, help with automation

    Hi.
    I have added an "On Leave" boolean field, on the user entity.
    I also added a "Parked" status on the cases entity.

    I am trying to make a workflow in advanced pack to auto switch the status of all the assigned user's cases to "Parked" when the user makes the On Leave field to true.
    When I start from target entity "User" I have no option to change the related cases.

    Any ideas?

  • #2
    Hi Emmker,

    As of EspoCRM v8.0 (record\findMany() function for formula script was added), you can use the following workflow:

    Click image for larger version

Name:	image.png
Views:	69
Size:	58.4 KB
ID:	100174

    Execute Formula Script action:
    Code:
    $userId = workflow\targetEntity\attribute('id');
    $casesIds = record\findMany('Case', 10000, 'createdAt', 'desc', 'assignedUserId=', $userId);
    
    $i = 0;
    
    while ($i < array\length($casesIds)) {
    
       record\update('Case', array\at($casesIds, $i), 'status', 'Parked');
       $i = $i + 1;
    }
    ​​

    Comment

    Working...
    X