Recalculation and Data Sync script for ClosePlan Templates
Categories and Questions in the Scorecard section of ClosePlan Templates can be synced with Fields on the Opportunity, ClosePlan, Account and/or other Objects for reporting purposes. Generally this is done before the Template is activated and deployed to Opportunities or Accounts, but occasionally syncing is done after the Template is deployed.
In this case, the synced Categories and Questions will not display updated data in Reports until the state of the Scorecard is changed, triggering an update.
In order to trigger an update for a Template that is already deployed, you can do it manually for each Opportunity or Account in which the Template is deployed, or use the below script in the DevConsole. Using the Developers Console requires the User to be a SysAdmin.
Data Sync Script
Id templateId = 'YOUR_TEMPLATE_ID';
TSPC.CPSJob_DealRehab job = new TSPC.CPSJob_DealRehab(new Id[]{ templateId},null,null);
job.scRescore = true;
job.scSyncFields = true;
Id jobId = Database.executeBatch(job, 10);
System.debug(jobId);Update Deployed a Template
In Salesforce, go to the gear icon > Developer Console > Debug > click Open Execute Anonymous Window > copy and paste the Data Sync Script
Replace YOUR_TEMPLATE_ID with the ID of your Template.
Click Execute
To Find the Template ID:
Go to ClosePlan Admin > Templates > Select the Template > Copy the Template ID.
Additional Resources
Category and Question Sync settings