Views:

Scenario Overview


The business scenario here is that you have an Accountancy firm that generates end of year accounts for its customers. At the end of the financial year for each customer they need to send an email with the end of year accounts & a signature page. These two documents will be attached to the Account entity. Please note this is a very simple setup for the sample just to get the concept across. In reality there would be a more robust way to select \ find the attachments.

So in this scenario the users needed the ability to execute a workflow on an Account record which would, 

  • Generate an Email
  • Find all the attachments on the account record
  • Add these attachments to the Email created above

Account Record

Email Record

N52 Formula Manager Solution

The Formula Manager solution works like this,

  • A formula of type 'Process Genie' is created so it can execute as a step within a workflow
  • When it reaches the 'Process Genie' step in the workflow it will execute the formula
  • The formula looks up the list of Case IDs associated to the current account
  • It then creates a note record associated to the account with this list

N52 Formula Manager Steps

The following set of steps outline how to create this Formula

  • Create a new formula of type 'Process Genie'
  • Set the Source Entity to 'Email'
  • Copy & paste the formula below into the formula 
  • Click save

Workflow Steps

The following set of steps outline how to create this Formula

  • Create a new workflow named 'Generate Email with Attachments'
  • Set it to run only 'On Demand'
  • Add a new step to create an email
  • Add a new step to the workflow to call the North52 Process Genie
  • Set the formula shortcode to be the one on the formula you just created, in this case 'vbG'
  • Set the Primary Entity ID to be the Dynamics Record URL of the create Email step
  • Add a step to change the status of the email to 'Pending Send'
  • Publish the workflow
  • You are now ready to test

 

Formula

ForEachRecord(

             FindRecords('annotation', 'objectid', [email.regardingobjectid] , '*'), 
  
             if( CurrentRecord('isdocument') = true,
                       
                     CreateNote('title',
                                 'email',
                                 [email.activityid] ,
                                 '',
                                 CurrentRecord('filename'), 
                                 CurrentRecord('mimetype'), 
                                 CurrentRecord('documentbody')
                                ),
               
                     CreateNote('title',
                                 'email',
                                 [email.activityid] ,
                                 '',
                                 'UserNotes.txt', 
                                 'text/plain', 
                                 Base64Encode(CurrentRecord('notetext'))
                                )
               )

    )

Wizard - FindRecords

Please see below the wizard you can use to create the FindRecords() function call used in this formula. 

Note to find the value for Equals Value, you will need to go to the Source tab and search for "regarding" . 

Also for annotation, search for "Note"