Scenario Overview
In your business, you may wish for a Quality team to randomly review the work of users. 
In this scenario, we are required to present to this Quality team a random portion of all the completed Tasks, PhoneCalls and Appointments that have been created today.
This can be done using a custom entity (called Activity Oversight) and North52 formula. 
North52 Decision Suite Solution
The North52 Decision Suite solution works like this:
- A formula of type Process Genie will be created that will will enact the bulk of the workload
- The formula is triggered by a Quick button on a Form
- The formula will query all the activities that have been created and completed today
- It will then create a record in our custom entity Activity Oversight for four randomly selected activities
- It populates each of these Activity Oversights with information from the collection of entities
N52 Create custom Entity Activity Oversight
- Go to Settings > Customization > Customize the System
- Click on Entities
- Click on New
- For Display Name, enter "Activity Oversight"
- For Plural Name, enter "Activity Oversight"
- For Name, make sure it is new_activityoversight
- Click Save
- Expand the entity and click on Fields
- Create 2 new fields new_activitytypecode , new_approved
- Add them to the form and publish the changes
North52 Decision Suite Steps
The following set of steps outline how to create this Formula:
- Create a new formula of type Process Genie
- Set the Mode to 'ServerSide'
- Set Display Format to 'String'
- Set the Source Entity to 'Account'
- Go to the Formula editor
- Copy and paste the formula below
- Click Save
- Copy the Short Code in the top right hand corner for later
 Formula
Formula
Smartflow(
        SetVar('PhoneCall Collection' ,
              FindRecordsFD('Find all Completed PhoneCalls created today','true')), 
        SetVar('Task Collection' , FindRecordsFD('Find all Completed Tasks created today','true')), 
        SetVar('Appointment Collection' , 
              FindRecordsFD('Find all Completed Appointment created today','true')),   
    SetVar('Master Collection',MergeEntityCollections(GetVar('PhoneCall Collection'),
                                                      GetVar('Task Collection'),
                                                      GetVar('Appointment Collection') )  ),
  
    ForEachRecord(
  
              RandomCollectionOfIntegers(0, FindECCount(GetVar('Master Collection')), 4),
  
                CreateRecord('new_activityoversight', 
                                    SetAttribute('new_name',
                                                FindRecordsValue(GetVar('Master Collection'),
                                               'subject', '?', CurrentRecord('randomnumber') ) ),
                                     SetAttribute('new_actvitytypecode', 
                                                 FindRecordsValue(GetVar('Master Collection'), 
                                                'activitytypecode', '?', CurrentRecord('randomnumber') ) )
                     )
            ) 
  
)N52 Create a quick button
Please follow the instructions at the link here, using the Shortcode of the formula you made above.
Wizard - FindRecordsFD
Please see below the wizard you can use to create the FindRecordsFD() function call used in this formula. 
Note you will need to create the Fetch Xml beforehand.  
 
 
		
 
 