Add automatic post-processing
- 16 Mar 2023
- 1 Minute to read
- Print
- DarkLight
Add automatic post-processing
- Updated on 16 Mar 2023
- 1 Minute to read
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
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.
- 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>
- 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();
}
})
- 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?