Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
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;
		}
	}
}


Info

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'

...