Add automatic post-processing
  • 16 Mar 2023
  • 1 Minute to read
  • Dark
    Light

Add automatic post-processing

  • Dark
    Light

Article summary

You can add automatic post-processing with some custom business logic. For example, you can configure additional calculations or data updates, then specify a custom toast message for when the specific template is applied.

  1. Create a Lightning component that will provide the handler code for the ApplyTemplateCompletedEvent.

Example of a SampleApplyTemplateEventHandler component:

<aura:component description="SampleApplyTemplateEventHandler"
                implements="flexipage:availableForAllPageTypes">
    <aura:handler event="c:ApplyTemplateCompletedEvent" action="{!c.handleApplyTemplateCompletedEvent}"/>
</aura:component>
  1. Create a SampleApplyTemplateEventHandler controller where you can specify pre- or post-processing actions and a custom toast message.
({
    handleApplyTemplateCompletedEvent: function (component, event, helper) {
        console.log('At the top of handleApplyTemplateCompletedEvent');
 
        // get the params
        let params = event.getParams();
        let templateId = params["templateId"];
        let targetObjectId = params["targetObjectId"];
 
        console.log('templateId: ' + templateId + ' targetObjectId: ' + targetObjectId);
 
        const toastEvent = $A.get("e.force:showToast");
        const successMessage = 'Custom success message - applied template: ' + templateId + 'target: ' + targetObjectId;
 
        toastEvent.setParams({
            type: 'success',
            message: successMessage,
        });
        toastEvent.fire();
        $A.get("e.force:refreshView").fire();
    }
})
  1. Add this component to the Lightning page.
Note
  • By default, the Show Message On Successful Apply checkbox is selected and a standard toast message Template Name was successfully applied appears.
  • You can clear the Show Message On Successful Apply checkbox. In this case, the toast message about a successful template application does not appear.

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.