Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Current »

By default, Users deploy ClosePlans to Opportunities manually by clicking on the Create button. If there is only one Template available, it is automatically selected for deployment, otherwise, the User will choose which Template to deploy.

Sometimes there is a need to deploy ClosePlans automatically based on Opportunity creation or other criteria. ClosePlan provides several ways to achieve this.

Template Selection

In order to use automated deployment, the Template which will be used for deployment must be specified. You can work with specific versions and easily get the version IDs directly from the ClosePlan Admin Template detail, or you can implement logic to retrieve the latest version for a specific Template based on specific Opportunity data.

ClosePlan in-template filter configuration works only from the UI during manual deployment so you must decide which template to use for which Opportunity. You can replicate the original filtering, but you can also achieve much more complex logic if needed.

If your organization uses Opportunity Record Types with multiple Sales Processes, and ClosePlan Templates have Staging functionality enabled for Playbooks, remember, that the destination Opportunities must use the same Sales Process as defined in the Template. Otherwise, deployment will be canceled.

Opportunity Selection

In order to use automated deployment, you will need to specify to which Opportunities ClosePlan should be deployed.

This is usually achieved using Opportunity Triggers, using records that are being currently updated in conjunction with any additional logic.

You may also query any Opportunities using SOQL with any conditions you like.

If you try to Deploy a ClosePlan to Opportunity that already has a ClosePlan, the deployment will be canceled. You can always determine if a ClosePlan exists by checking TSPC__CPDeal__c field on the Opportunity. This field will be null if no ClosePlan exists.

Deployment using APEX

There are two ways to deploy for APEX, synchronous and asynchronous.

The synchronous approach supports a single Opportunity record deployment at a time only, and it is an ideal if you expect that the user should see ClosePlan in place immediately after the transaction completes. For multiple Opportunity deployment, you should use an asynchronous approach or switch between both based on data-set size. The asynchronous approach will not slow down the running users.

The logic of when the deployment should occur is solely up to you, but usually it is triggered after Opportunity creation, Stage change, or any other plausible criteria.

Deploying through APEX is the most efficient method and allows you to handle complex logic and decisions.

Asynchronous Deployment using Batch job

  • Ability to deploy multiple records

  • Async run won’t slow down users

  • It might take few seconds until ClosePlan appears in the UI

  • Can be invoked from Triggers or any Apex class

// Provide Template ID
// Note: You can use static template ID or retrieve the latest version for particular Template
Id templateId  = 'a684R000000H7HOQA0';
// Provide set of Opportunity Ids, which should be deployed
Set<Id> oppIds = new Set<Id>{'0060Y00000B8XcX'};

// Create deploy job and execute
TSPC.CPSJob_DealDeploy job = new TSPC.CPSJob_DealDeploy(oppIds, templateId);
Id jobId = DataBase.executeBatch(job, 5); // Max 10 - Tweak depending on template complexity. 

Synchronous Deployment

  • Ability to deploy only to single Opportunity

  • Might slow down users

  • Available immediately after transaction completes

  • Can be invoked from Triggers or any Apex class

// Provide Template ID
// Note: You can use static template ID or retrieve the latest version for particular Template
Id templateId  = 'a684R000000H7HOQA0';
// Provide Opportunity ID
Id opportunityId = '0060Y00000B8XcX';

// Invoke deployment
TSPC.CPSJob_DealDeploy.deployDeal(opportunityId, templateId, null);

Deployment using Flows

The following example shows how to create a Salesforce Flow to assign a ClosePlan Template automatically whenever a new Opportunity is created.

  1. Setup > Process Automation > Flows

  2. Click New Flow

  3. Select Record-Triggered Flow

  4. Click Create

  5. For Select Object, select: Opportunity 

  6. For Configure Trigger, select: A record is created

  7. For Set Entry Conditions, define any conditions or none. In this example we will not define any conditions.

  8. For Optimize the Flow for, select: Actions and Related Records

  9. Click Done

  10. Click the plus sign in the circle to Add Element

  11. Select Action

  12. In the New Action modal window under Action, search for and enter: ClosePlan: Deploy Opportunity Template

  13. In the New Action modal, for Label: enter Deploy ClosePlan Template. The API Name will autofill.

  14. Under Set input Values, find $Record Opportunity and click to enter, then click outside of the box. The value should read: {!$Record} - 

  15. Note: The value may sometimes read: {!$Record.} - the period after ‘Record’ must be deleted.

  16. If there is only one active ClosePlan Template, leave the ‘Don’t Include’ toggle switch off. The Flow will then deploy the only Active Template.

  17. If there is more than one Template Active, and you want a specific Template deployed, go to:
    ClosePlan Admin tab > Templates > Copy the Template ID. 
    You will then activate the toggle switch and paste the Template ID in the field.

  18. Click Done 

  19. Click Save 

  20. For Flow Label enter: Deploy ClosePlan Template. The Flow API Name will autofill.

  21. Click Save 

  22. Click Activate to activate the Flow

  • No labels