AdvoLogix Help

Creating an Activity Plan via Code

Updated on

The following Apex method can be used create an Activity Plan via custom coding. Please be aware this method uses asynchronous processing techniques that require knowledge of Force.com best practices as they relate to asynchronous processing. It is always suggested to test your code in the Sandbox.

Syntax:
ActionPlansUtilitiesExternal.ApplyActionPlan(
    @newActionPlanName,     
    @templateId,     
    @recordId,     
    @objectApiName
);
 
Parameters:
@newActionPlanName
The name of the newly created Activity Plan.

@templateId 
The record ID of the Activity Plan Template to be used for the new Activity Plan.

@recordId
The record ID of the source object the new Activity Plan is being created for. This will be either a Matter, Account or Contact ID as specified in the next parameter.

@objectApiName
The API name of the base object for the ID specified in the record ID.
Options are 'advpm__Matter__c' for Matter, 'Account' for Account and 'Contact' for Contact.

Result:
The function call will return a JSON formatted string in this format: {success:"",result:""} 

success
Will be either TRUE or FALSE

result
Confirmation message of process completion OR Error message if process is hauled with any unexpected error.  

Example:
ActionPlansUtilitiesExternal.ApplyActionPlan(
    'My New ActionPlan',  
    'a0A9000000RJhKTEA1',  
    'a05900000051CpN',  
    'advpm__Matter__c'
);

Note:
Multiple recordId parameters can be passed to create a multiple new Activity Plans for several Matter objects with a single function call. Use a ',' (comma) to separate the ID values. e.g: 'a05900000051CpN,a05900000052CpN,a05900000053CpN'  

Example Using a Button from the Matter Context 

Previous Article How do activity plan dependencies work?
Next Article Adding an Activity to an Activity Plan via Code
Still need help? Click here!
AdvoLogix® is a registered trademark of AdvoLogix.com LLC a Texas Limited Liability Company. All references to other trademarks belonging to third parties that appear on this website, documentation, or other materials shall be understood to refer to those registered trademarks owned by others, and not to any trademark belonging to AdvoLogix. Otherwise, all material herein is the copyright of AdvoLogix.com LLC. All Rights Reserved.