Views:

Scenario Overview

In this scenario we have the need that whenever the description field changes on a Case record we have to update this new description text to a custom field call workscope on the email entity for all related sent emails. The tricky part here is that we need to re-open the email so we can set the workscope field.

This sample demonstrates how to execute multiple statements within a ForEachRecord() function call. 

N52 Formula Manager Solution

The Formula Manager solution works like this,

  • A formula is created which executes on the Update of the Description field on the Case entity
  • The formula first finds all related emails which have been marked as sent 
  • Then for each email it performs 3 actions 
  • Action 1: Set the email back to draft
  • Action 2: Update the workscope field with the description field from the Case
  • Action 3: Set the email back to it original status of sent.


N52 Formula Manager Steps

  • Create a new formula of type 'Save - Perform Action'
  • Set the Event to 'Update'
  • Set the Source Entity to 'Case'
  • Set the Source Property to 'Description'
  • Copy & paste the formula below into the formula description field & click save
  • You are now ready to test

Formula

ForEachRecord(

     FindRecords('email', 
                 SetFindAnd('regardingobjectid', 'statuscode'),
                 SetFindAnd([incident.incidentid], '3') , 'activityid'), 

     UpdateRecord('email',
                 CurrentRecord('activityid'),
                  SetAttributeStatus(0,1)),

      UpdateRecord('email',
                   CurrentRecord('activityid'),
                   SetAttribute('new_workscope', [incident.description] )),

      UpdateRecord('email',
                  CurrentRecord('activityid'),
                  SetAttributeStatus(1,3))
)