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 8 Next »


Booker25 allows you to define an interface which you can use to add custom logic when Templates are being created on the Calendar. This is useful for pre-populating fields for example.

 

To add your own logic on Template creation:

  1. Create a global class that implements the Callable interface (see https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_System_Callable.htm )

  2. Implement the 'call' method in this class. This method will be called with a string value of 'onCreateTemplate' and a map with key 'template' whose value is the B25__Reservation_Template__c record that is being created.

  3. The 'call' method should return an object of type B25__Reservation_Template__c, with values in the fields that you want to pre-populate.

  4. Create a Custom Setting (of type B25 System Setting) with name 'Template On Create Class' and as value the name of the class you created in step 1.

Example

global with sharing class MyTemplateHook implements Callable {

	global Object call(String action, Map<String,Object> args) {

		// check which action is being called,
		// in case you are reusing this class for multiple purposes
		if (action == 'onCreateTemplate') {
			
			// get the record
			B25__Reservation_Template__c recordBeingCreated = args.get('template');

			// pre-populate values
			recordBeingCreated.B25__Number_Of_Sessions__c = 10;

			// return the record
			return recordBeingCreated;

		} else {

			// another action was called
			// this is possible if you are reusing this class for multiple purposes
			// for this example we return null as a fallback
			return null;
		}
	}
}


If you are following along with the above example, don't forget to create a B25__System_Setting__c custom setting with name 'Template On Create Class' and value 'MyTemplateHook'



On this page

  • No labels