Loading

Run Territory Planning Permanently Delete job from a Flow

Veröffentlichungsdatum: Aug 22, 2023
Beschreibung
A scheduled flow can be used to periodically run the TPCleanupBatch job without needing to go to the settings page and manually click the button in order to delete the deleted Data Sets and Alignments permanently. Running this job often will reduce storage, and improve application performance.
Lösung

Detailed Steps to create the Apex class and Flow are as follows:


1) Create a new Apex Class

  1. Navigate to Setup | Apex Classes | New
  2. Paste the following code, and Save
public class RunTPCleanUp {
  @InvocableMethod(label='Run TP CleanUp' description='Removes deleted data sets and alignments' category='Maps')
  public static void RunTPCleanUp(List<ID> ids) {
    AsyncApexJob cleanupJob = maps.TPSDK.DoCleanup();
        System.debug('Cleanup job is ' +cleanupJob.Status+ '.  '  +cleanupJob.JobItemsProcessed+ ' of ' +cleanupJob.TotalJobItems+ ' batches processed.');
  }
}


2) Create a new Schedule-Triggered flow

  1. Navigate to Setup | Flows | New
  2. Select Schedule-Triggered Flow
  3. Select Freeform
  4. Click Set Schedule to set a defined schedule for the job to run 
  5. Add Elements | Action
  6. Under Category, Select Maps, and under Actions select Run TP CleanUp
    1. Set a Label & API value
    2. Do not set Input Values
  7. Click Done
  8. Save Flow
  9. Activate the flow
This flow should trigger the Permanently Delete job to run in the background according to the frequency set in the flow.


After saving the flow, you can test if it is running without any errors by selecting Debug | Run from the edit Flow screen. You can then navigate to the Setup | Apex Jobs to ensure that the TPCleanupBatch job kicked off successfully.
 

NOTE: You can also have the job skip the Recycle Bin by checking the Skip Recycle Bin option from Settings | Data Management (Spring ‘22+). We strongly recommend this to be tried and tested in Sandbox before deploying to Production.
Nummer des Knowledge-Artikels

000389556

 
Laden
Salesforce Help | Article