Hi Ben,
Before I dive into answering some of your questions, I want to mention something that you may or may not realize about the standard e-mail notification templates. The templates are used site-wide for all workflows. This means that any changes that you make to the template will be reflected in all current and future workflows for all of their notifications. If you only use one workflow for your entire system right now, this probably isn't a concern. But this is something to keep in mind as you continue to expand your use of Windchill (i.e. promotion request process, change requests, change notices, etc.).
With that in mind, the approach that I like to take is to not change anything within the given General_en_US.html template, but to simply add to it in a way that allows me to customize the subject and text of the notifications within the workflow itself.
If you open your Windchill Help Center and search for "Workflow Email Notifications", you will find the topic containing the standard scripts that you can add to the template to customize it. Here's a snippet:
Common Methods
- addText text="<value>"
- getActivityName
- getActivityVariable varName="<Variable Name>" (not applicable for Notification Robot)
- getInitSubject
- getPrimaryBusinessObjectName
- getProcessName
- getProcessVariable varName="< Variable Name >"
Methods for Workflow Task Notification
- activityAttributes (This method shall be used in body only)
- activityNotificationUrl (This method shall be used in body only)
- getDeadline
Let's say you want to make the subject of the e-mail contain the name of the primary business object followed by the activity name and you want to add the value of a String variable created within the workflow named "EmailText". The template might become something like this:
<html>
<SCRIPT LANGUAGE=Windchill> <!-- beginSubject --> </SCRIPT>
<SCRIPT LANGUAGE=Windchill> <!-- getPrimaryBusinessObjectName --> </SCRIPT>
<SCRIPT LANGUAGE=Windchill> <!-- addText text=" - " --> </SCRIPT>
<SCRIPT LANGUAGE=Windchill> <!-- getActivityName --> </SCRIPT>
<SCRIPT LANGUAGE=Windchill> <!-- endSubject --> </SCRIPT>
<head>
<SCRIPT LANGUAGE=Windchill>
<!-- getStyleSheetProps -->
</SCRIPT>
</head>
<body>
<font face="Arial, Helvetica, sans-serif">
<SCRIPT LANGUAGE=Windchill> <!-- getProcessVariable varName="EmailText" --> </SCRIPT>
</font></BR></BR>
<font face="Arial, Helvetica, sans-serif">
<SCRIPT LANGUAGE=Windchill> activityNotificationUrl </SCRIPT>
</font>
<SCRIPT LANGUAGE=Windchill>
<!-- activityAttributes notification=true -->
</SCRIPT>
</body>
</html>
Comparing this to the original template, this will cause all workflow task notifications to add the primary business object's name to the front of the standard activity name already included in standard notifications. But, this will only add custom text to the notification based on a workflow variable being created within the workflow template. If the EmailText variable exists in the template and contains a value, that text will be included in the notification. If the variable doesn't exist in the workflow, the text will not be displayed. This helps you to control what the notifications say within the workflow itself as opposed to having a standard notification across all tasks in all workflows.
Take a look at the Help Center documentation and play around with some of the other options provided. I've never dug as deep as to create my own custom scripts for this, so I can't provide you with direction there. I've always found the scripts provided to be flexible enough for my needs.
Hopefully, this all makes sense and can get you going in the right direction.