locked
SCSM custom workflows assign to user, adding notifications with HTML into XML RRS feed

  • Question

  • I have been looking for a good way to notify user/analyst when an incident is assigned or reassigned. It seems this is not possible to do this with the workflow creator from the console.

    There are several custom management packs out there which do this fine, but they only send normal text in the message body. I have been trying to include HTML into the xml message area, but SCSM will only validate text only in the element.

    Heres an example of where i wish to incorporate html:

            

     <Templates>

        <ObjectTemplate ID="IncidentAssignedToUserNotificationTemplate" TypeID="CustomSystem_Notifications_Library!System.Notification.Template.SMTP">
          <Property Path="$Context/Property[Type='CustomSystem_Notifications_Library!System.Notification.Template.SMTP']/Subject$">&lt;1033&gt;[$Context/Property[Type='WorkItem!System.WorkItem']/Id$]    -    $Context/Property[Type='WorkItem!System.WorkItem']/Title$&lt;/1033&gt;</Property>
          <Property Path="$Context/Property[Type='CustomSystem_Notifications_Library!System.Notification.Template.SMTP']/Priority$">2</Property>
          <Property Path="$Context/Property[Type='CustomSystem_Notifications_Library!System.Notification.Template.SMTP']/IsBodyHtml$">True</Property>
          <Property Path="$Context/Property[Type='CustomSystem_Notifications_Library!System.Notification.Template']/Content$">&lt;1033&gt;


    $Context/Property[Type='WorkItem!System.WorkItem']/Id$ has been assigned to you.
    >>>>HTML CODE<<<<

    &lt;/1033&gt;</Property>


    Is it possible to add html into the custom MP, or alternatively telling it to use a html notification template i have already created in the console? 

    Friday, September 28, 2012 11:04 AM

Answers

  • There are a couple ways you can do this:

    If you already have an email template with html code in it, open up the MP where it's contained and copy the content fields to the other email template (that you showed above). You'll notice that, in an MP, html code is "converted"..basically, left and right arrows (< and >) are converted to &lt; and &gt;..this is so the management pack import process will not mistake HTML code for XML code.

    The other way to do this is to edit the workflow configuration in the XML. In the <writeaction> node, you'll notice one of the workflow parameters asks for a TemplateId..if you find the template Id of the email template you wish to you, you can put that Guid into that parameter. You can get an object template's guid from the ObjectTemplate table in the database.

    • Marked as answer by AndersAsp Friday, September 26, 2014 8:46 AM
    Friday, September 28, 2012 1:46 PM
  • There are a couple ways you can do this:

    If you already have an email template with html code in it, open up the MP where it's contained and copy the content fields to the other email template (that you showed above). You'll notice that, in an MP, html code is "converted"..basically, left and right arrows (< and >) are converted to &lt; and &gt;..this is so the management pack import process will not mistake HTML code for XML code.

    The other way to do this is to edit the workflow configuration in the XML. In the <writeaction> node, you'll notice one of the workflow parameters asks for a TemplateId..if you find the template Id of the email template you wish to you, you can put that Guid into that parameter. You can get an object template's guid from the ObjectTemplate table in the database.

    With the need to update html templates frequently, i attempted your last suggestion. It sure made life alot easier. It was somewhat tricky to find the GUID on custom templates as the object template name is unreadable, ended up editing the default scsm templates.

    Thanks again for the suggestion.

    For anyone curious heres an example.

    Getting template GUID

    Run a query in the scsm sql database "select * from objecttemplate", look for the correct ObjectTemplateName, there should be a templateID there which is the GUID.

    Editing xml:

    <WorkflowArrayParameter Name="NotificationTemplateIdList" Type="guid">
                        <Item>INSERT TEMPLATE GUID HERE</Item>

    Or look below for a better context.

     <WriteActions>
              <WriteAction ID="WA" TypeID="SystemCenter!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction">
                <Subscription>
                  <EnableBatchProcessing>false</EnableBatchProcessing>
                  <WindowsWorkflowConfiguration>
                    <AssemblyName>Microsoft.EnterpriseManagement.WorkflowFoundation</AssemblyName>
                    <WorkflowTypeName>Microsoft.EnterpriseManagement.WorkflowFoundation.ConfigurationWorkflow</WorkflowTypeName>
                    <WorkflowParameters>
                      <WorkflowParameter Name="InstanceId" Type="guid">$Data/BaseManagedEntityId$</WorkflowParameter>
                      <WorkflowArrayParameter Name="UserRelationshipIdList" Type="guid">
                        <Item>$MPElement[Name='WorkItem!System.WorkItemAssignedToUser']$</Item>
                      </WorkflowArrayParameter>
                      <WorkflowArrayParameter Name="NotificationTemplateIdList" Type="guid">
                        <Item>INSERT TEMPLATE GUID HERE</Item>
                      </WorkflowArrayParameter>
                    </WorkflowParameters>
                    <RetryExceptions />
                    <RetryDelaySeconds>60</RetryDelaySeconds>
                    <MaximumRunningTimeSeconds>7200</MaximumRunningTimeSeconds>
                  </WindowsWorkflowConfiguration>
                </Subscription>
              </WriteAction>
            </WriteActions>

    • Marked as answer by AndersAsp Friday, September 26, 2014 8:46 AM
    Thursday, October 11, 2012 2:57 PM
  • You can also get this info via powershell and smlets:

    foreach ($template in (Get-SCSMObjectTemplate))
    {
        echo $template.Id
        echo $template.Name
        echo $template.Description
    }

    • Marked as answer by AndersAsp Friday, September 26, 2014 8:46 AM
    Friday, September 19, 2014 9:21 PM

All replies

  • There are a couple ways you can do this:

    If you already have an email template with html code in it, open up the MP where it's contained and copy the content fields to the other email template (that you showed above). You'll notice that, in an MP, html code is "converted"..basically, left and right arrows (< and >) are converted to &lt; and &gt;..this is so the management pack import process will not mistake HTML code for XML code.

    The other way to do this is to edit the workflow configuration in the XML. In the <writeaction> node, you'll notice one of the workflow parameters asks for a TemplateId..if you find the template Id of the email template you wish to you, you can put that Guid into that parameter. You can get an object template's guid from the ObjectTemplate table in the database.

    • Marked as answer by AndersAsp Friday, September 26, 2014 8:46 AM
    Friday, September 28, 2012 1:46 PM
  • Ended up replacing '<' and '>' with '&amp;lt;' and ';gt;', worked very well, but somewhat messy (mass replace of < > when html was done) to edit html documents this way if changed later are needed.  Thanks for the alternative solutions :)

     &amp;lt;!DOCTYPE html&amp;gt;
    &amp;lt;html lang="en"&amp;gt;
      &amp;lt;head&amp;gt;
        &amp;lt;meta charset="utf-8"&amp;gt;
        &amp;lt;meta name="dcterms.created" content="on, 26 sep 2012 13:07:21 GMT"&amp;gt;
        &amp;lt;meta name="description" content=""&amp;gt;
        &amp;lt;meta name="keywords" content=""&amp;gt;
        &amp;lt;title&amp;gt;

    Example

    Friday, September 28, 2012 2:01 PM
  • There are a couple ways you can do this:

    If you already have an email template with html code in it, open up the MP where it's contained and copy the content fields to the other email template (that you showed above). You'll notice that, in an MP, html code is "converted"..basically, left and right arrows (< and >) are converted to &lt; and &gt;..this is so the management pack import process will not mistake HTML code for XML code.

    The other way to do this is to edit the workflow configuration in the XML. In the <writeaction> node, you'll notice one of the workflow parameters asks for a TemplateId..if you find the template Id of the email template you wish to you, you can put that Guid into that parameter. You can get an object template's guid from the ObjectTemplate table in the database.

    With the need to update html templates frequently, i attempted your last suggestion. It sure made life alot easier. It was somewhat tricky to find the GUID on custom templates as the object template name is unreadable, ended up editing the default scsm templates.

    Thanks again for the suggestion.

    For anyone curious heres an example.

    Getting template GUID

    Run a query in the scsm sql database "select * from objecttemplate", look for the correct ObjectTemplateName, there should be a templateID there which is the GUID.

    Editing xml:

    <WorkflowArrayParameter Name="NotificationTemplateIdList" Type="guid">
                        <Item>INSERT TEMPLATE GUID HERE</Item>

    Or look below for a better context.

     <WriteActions>
              <WriteAction ID="WA" TypeID="SystemCenter!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction">
                <Subscription>
                  <EnableBatchProcessing>false</EnableBatchProcessing>
                  <WindowsWorkflowConfiguration>
                    <AssemblyName>Microsoft.EnterpriseManagement.WorkflowFoundation</AssemblyName>
                    <WorkflowTypeName>Microsoft.EnterpriseManagement.WorkflowFoundation.ConfigurationWorkflow</WorkflowTypeName>
                    <WorkflowParameters>
                      <WorkflowParameter Name="InstanceId" Type="guid">$Data/BaseManagedEntityId$</WorkflowParameter>
                      <WorkflowArrayParameter Name="UserRelationshipIdList" Type="guid">
                        <Item>$MPElement[Name='WorkItem!System.WorkItemAssignedToUser']$</Item>
                      </WorkflowArrayParameter>
                      <WorkflowArrayParameter Name="NotificationTemplateIdList" Type="guid">
                        <Item>INSERT TEMPLATE GUID HERE</Item>
                      </WorkflowArrayParameter>
                    </WorkflowParameters>
                    <RetryExceptions />
                    <RetryDelaySeconds>60</RetryDelaySeconds>
                    <MaximumRunningTimeSeconds>7200</MaximumRunningTimeSeconds>
                  </WindowsWorkflowConfiguration>
                </Subscription>
              </WriteAction>
            </WriteActions>

    • Marked as answer by AndersAsp Friday, September 26, 2014 8:46 AM
    Thursday, October 11, 2012 2:57 PM
  • You can also get this info via powershell and smlets:

    foreach ($template in (Get-SCSMObjectTemplate))
    {
        echo $template.Id
        echo $template.Name
        echo $template.Description
    }

    • Marked as answer by AndersAsp Friday, September 26, 2014 8:46 AM
    Friday, September 19, 2014 9:21 PM
  • You can also reference MP like this, so you don't have to look for the GUID:
                      <WorkflowArrayParameter Name="TemplateIds" Type="string">
                        <Item>$MPElement[Name='Template_dde4cf07392e4159943a9bada8559c80']$</Item>
                      </WorkflowArrayParameter>
    • Edited by _Keith_ Tuesday, September 23, 2014 8:26 PM
    Tuesday, September 23, 2014 7:55 PM