cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Custom Workflow Email Notifications

bwilcox
12-Amethyst

Custom Workflow Email Notifications

We are looking at trying to customize the appearance of the email notifications that get sent for workflow activities and workflow notification robots. I have found the information on customizing the workflow HTML templates and have found the directories where they are stored on our server, but I do not know the best way to go about customizing the HTML files to make them work properly with our system. We are using Windchill 10.0 M040.

What I am looking for is a sample template that we could use as a starting point for developing our own email templates.

Also, where are the scripts located that Windchill uses for generating the email content? The General_en_US.html template uses three scripts: getStyleSheetProps, activityNotificationUrl, and activityAttributes notification=true. In order to develop our own template, do I need to create my own custom scripts so that I can insert dynamic information relating to the workflow activity, etc.?

I am a novice when it comes to HTML and Java development, so any help will be greatly appreciated.

Thank you,

Benjamin Wilcox IntelliServ

Portfolio, Project & Data Management Administrator

Learn about the second generation Wired Drill Pipe Network > IntelliServ2

ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

5 REPLIES 5

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.

Garrett,

Thank you for the information. It is very informative. I was aware of the fact that changing the email templates would affect all workflow notifications - hence my interest in the scripts that they use.

I tried looking up "Workflow Email Notifications" in the Windchill Help Center, but I do not get much useful information there. It just gives generic information, saying that you can make custom templates and refers you to the Customization Guide, but the Customization Guide doesn't talk about the scripts for email customization.

Are you using a different version of Windchill? I am on Windchill 10.0 M040.

I do have a copy of the Windchill Java Doc and API, but I don't know where to look for the methods to which you are referring. Do you know which class they are in?

Thanks,

Ben

Hi Ben,

The Help Center may differ because I'm using Windchill 10.1. PTC may have added functionality in this area (or simply added to their documentation) between point releases.

I'm not aware of how to customize these scripts or where in the codebase that they are located. That's going beyond the standard supported API that you will find in the Java doc. You will probably need to go directly to PTC for information like that.

I would still encourage you to test the "getProcessVariable" script noted above. If this works in 10.0, it gives you the freedom to add supported API calls directly within each workflow (within an expression robot) to create a String variable of what you need to add to the notifications. Then you can simply add each variable throughout the template as required.

Anyone else with any experience in this area that can help Ben?

We just updated to 10.1 last weekend, and I am now able to see what you were seeing in the Help Center. It is useful information. Thank you for pointing me to that and for your suggestions about using a workflow variable for email customization. I will experiment with this.

Zoltán
13-Aquamarine
(To:ptc-4482159)

Old topic but still relevant in Release: 12.0.2.14.

Your text helped me to better understand these settings.

Just to help other rookies out with understanding the connection between the html and the email, I'll add two pictures below.

 

As @James62 says in his post here, if something doesn't compute, the email will be blank.

Announcements


Top Tags