- Home
- Blog
- System Center 2012 Service Manager
- How to use SCUtils FileAttachment to send notifications with attachment links
How to use SCUtils FileAttachment to send notifications with attachment links
After SCUtils FileAttachment was released, we started to receive questions about the use of this add-on. For those who can use Orchestrator to send the notification, using the solution is a very simple and straight task. But if you want to use the notification templates of Microsoft System Center 2012 Service manager, it could be a bit complex thing.
The issue raises when you have multiple attachments. In this case, you cannot create a link for each file attachment because for the following template code
http://ssp2:81/ContentHost/ClientBin/AttachmentViewer.aspx?InstanceID=$Context/Path[Relationship='CustomSystem_WorkItem_Library!System.WorkItemHasFileAttachment' TypeConstraint='CustomSystem_SupportingItem_Library!System.FileAttachment']$?$Id$?
the Service Manager inserts
http://ssp2:81/ContentHost/ClientBin/AttachmentViewer.aspx?InstanceID=D193DA70-32BB-77BD-0DA4-05A0EF9C8A2D;25903DC5-CFFC-748C-F72C-194A5AE3CC0D
instead of
http://ssp2:81/ContentHost/ClientBin/AttachmentViewer.aspx?InstanceID=D193DA70-32BB-77BD-0DA4-05A0EF9C8A2D
http://ssp2:81/ContentHost/ClientBin/AttachmentViewer.aspx?InstanceID=25903DC5-CFFC-748C-F72C-194A5AE3CC0D
It happens because the SCSM returns an array of IDs injected as a semicolon separated line. As a result, the link is not working. Maybe someone knows how to format the email template using HTML tags to avoid this issue but unfortunately, I do not.
What I know is how to create a custom workflow in the Microsoft Visual Studio to send notifications using the “on-fly customized” template.
The idea is to inject the custom links from Parent Work Item to the email template in our custom workflow. This email template will be used to inform reviewers of a Review Activity.
I will use a keyword [attachments] in the body of the email template. The keyword will be replaced with the text contains the HTML code with the links.
My work is based on my previous blog posts here and here. So you can take a look in those codes if you want to see what it comes from.
To adapt the code for your environment, you have to make some changes. First, you need to replace http://ssp2:81 with the address of your WebContentServer in the following string (NotifyReviewerWithAttachLinks.cs)
"<br><a href=\"http://ssp2:81/ContentHost/ClientBin/AttachmentViewer.aspx?InstanceID={0}\">{1}<//a>"
And you probably will be eager to customize the email template by replacing my “text” with some more user-friendly content.
After you recompile the solution, copy NotifyReviewerWithAttachLinks.dll to the Service Manager folder on the management server, and then import SCUtils.NotifyReviewerWithAttachLinks.Workflow.xml management pack.
Please note that the solutions includes two workflows:
- Notify a reviewer with attachment links (reviewer is added) – sends a notification when a new reviewer is added to a Review Activity that has the status “In Progress”
- Notify a reviewer with attachment links (in progress) – sends a notification when a Review Activity’s status becomes “In Progress”
You can disable any of those workflows if required.
That is the result:
Categories: System Center 2012 Service Manager
Comments (8)
Petr Yakushov
For example:
$Context/Path[Relationship='CustomSystem_WorkItem_Library!System.WorkItemHasFileAttachment' TypeConstraint='SupportingItem_Library!System.FileAttachment']$?$DisplayName$?
reply
Marat Kuanyshev
This tag works only in the case of the only attachment.
reply
Pavel
Thank you for your work!
Improve please russian filenames support... The version 1.1 is still show fliename as "????????????.png"
reply
Pavel
reply
Marat Kuanyshev
reply
Marat Kuanyshev
reply
p.maksimov
reply
Marat Kuanyshev
reply