We have the business requirement of reusing the email templates from the Email Channel on Business cases.
On the business case we are using the Send email shape, but this shape only allows to use a pre-existing template on the system or to write a custom text for the email. We have come to the solution to create a wrapper template in our work pool, and just include the necessary templates based on the value of a property by using JSP Tags. The templates that are currently in use for the Email Channel are under the class (Work-Channel-Triage)
So far we have being partially successful, when using the tags pega:withPage to change the context and <pega:include name**>** to provide the name of the Corr rule, the last tag however only works if you know the name of the Corr rule on design time.
The other approach is to dynamically source the name of the Corr rule from a property by using the tag pega:save (Scratchpad) and then retrieve the saved value using $SAVE() when using the tag <pega:include ref**>**, this is not really working because apparently the system is always trying to find that rule @baseclass. Even if we have changed the context page as we did in the example above. In the example below we are using a hardcoded value instead of a property reference for POC purposes.
Error message in PEGA Logs: Could not find a rule when appending a stream com.pega.pegarules.pub.generator.RuleNotFoundException: Failed to find instance @baseclass.NoInvoiceOrObjectNumberReply_German.Email of type Rule-Obj-Corr.
If we save a copy of the template @baseclass then everything works! but it is not really an ideal solution for us since we would have 2 copies of the same template that could potentially be out of sync, as the business is actively modifying the ones on the email channel (Work-Channel-Triage class)
Any suggestions would be greatly appreciated.
Articles for reference:



