Manual and Review activities applied via a template to an existing work item are created without prefix

Manual and Review activities applied via a template to an existing work item are created without prefix

  • Comments 16
  • Likes

Folks, in our Phoenix blog post we promised greater community engagement from the PG on this forum... so here's a quick post documenting a workaround for a known issue in Service Manager.

There is an issue in Service Manager 2012+ when applying templates with embedded Manual or Review activities on existing Incidents and Service Requests. The update works as expected, however the activities created do not have the “MA” or “RA” prefix – so instead of the ID being MA254, it’s just 254.

In the Activities view you will see this:


Notice that the “MA” and “RA” prefixes are missing

instead of:


This becomes especially problematic when using the Exchange Connector because you will not be able to update the affected work items as it expects the prefix to be there. The same may also hold true for integration with Orchestrator.

For more information on how to configure workflows in Service Manager click here.

There is a workaround to get the prefixes back again. To get this working as expected, you can manually update each template and explicitly add the “MA” or “RA” prefix as follows:

  1. Export the MPs which contain the templates
  2. Open the XML in your favorite XML editor and do a “find” for the activity title, in this case I had named one of my activities “Prefix Test Manual Activity”. The XML line which you’re looking for should look something like this <Property Path="$Context/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Title$">Prefix Test Manual Activity</Property>
  3. The XML block should look like this:image
  4. One you’ve found this update your template by adding the following line as the first property for each Manual Activity <Property Path="$Context/Property[Type='CustomSystem_WorkItem_Activity_Library!System.WorkItem.Activity']/Id$">MA{0}</Property>
  5. and for each Review Activity add the following line <Property Path="$Context/Property[Type='CustomSystem_WorkItem_Activity_Library!System.WorkItem.Activity']/Id$">RA{0}</Property>
  6. Increase the MP version and import it back into Service Manager
  7. Restart the OMCFG service and make sure that the MP is downloaded and applied (events 1201 and 1210)

That’s it, you should now be able to apply Incident and Service Request templates with the included activities having the expected prefix.

Kudos to José, one of our escalation engineers, for sharing this fix. BTW, the team's tracking this bug in our backlog and will work towards fixing it in the coming URs.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Lee and I ran into this same problem about a year ago. Looking forward to the Update Rollup!

  • Yes! This was a massive pain, and while the workaround DOES work, you will have to REDO the steps when you modify the Template after implementing the workaround.

    However I would also like to mention another solution from Morten Meisler over on the Coretech blog: This solution avoids some of those issues!

  • Also Anton has some steps to avoid this problem when using the SDK

  • Great stuff. To work around the problem when using orchestrator, my small integration pack can be used

    Keep up all the great news! Good work :)
    - Jakob

  • Will this be addressed by the product team?

  • best engnineering JNIT is the top engineering college in jaipur and approved by AICTE and affiiated to Rajasthan Technical University, Kota. JNIT provide the best placement in rajasthan.
    No.1 Private Placement college in jaipur

  • A blend of Art & Science Technology and Tradition are taking place in the Hospitality Catering and Tourism Industry. This Sector is predicted to triple in size within the next 10 years and become the world’s largest industry by the year 2020, generating enormous opportunities for well qualified individuals armed with credentials from an elite institute like JIMS. These Graduates will be in great demand to assume exciting and rewarding positions anywhere in the World. Society has evolved from eating to relishing food. The “Cook” has become a “Chef”. The “Waiter” has become a “Steward”. Hotels are a part of the Hospitality Industry. To begin with the Indian Hotel Chain like ITC Ltd., The Jaypee Group, Oberoi Group, Asian Hotels Ltd., Hotel Leela Venture and Hotel Corporation of India are leaders providing a healthy competition and setting International Standards. Many International Hotels Including Sheraton, Hyatt, Radisson, Meridien, Four Seasons Reagent and Marriot International are already established in the Indian Market and are still expanding. Tourism is also now factored as a catalyst in the further development in the Hospitality Industry.

  • Is this fixed in SCSM 2012 R2 UR2 ?

  • Is this fixed yet, we have lots of templates... adding that many XML Inserts is not really feasible

  • I had to use this fix. I created a simple powershell script that will update each RA or MA in a management pack. This worked for me because I saved all of my templates to one management pack.

    $MA_init = @"
    Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' TypeConstraint='CustomSystem_WorkItem_Activity_Library!System.WorkItem.Activity.ManualActivity'
    $MA_new = @"
    $RA_init = @"
    Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' TypeConstraint='CustomSystem_WorkItem_Activity_Library!System.WorkItem.Activity.ReviewActivity'
    $RA_new = @"

    #Path to the exported Management Pack that needs to be updated
    $path = "C:\SCSM\MPName.xml"

    #Add the RA or MA line to the Management Pack after every line MA_Init or RA_Init line it finds.
    get-content $path | foreach-object{
    switch -regex ($_)
    }} | out-file C:\scsm\test2.xml

  • Hey guys, I don't know how to make a post here yet. I'm pretty new to the SCSM blog, but have been working with this tool for a bit now. I've noticed when you export the ManagementPack after having updated templates with activities the prefix ID disappears as described above. I find it too tedious to manually fix this and have written a script that we've put into our release pipeline which checks (and fixes if needed) the management packs before they're sealed and moved to the production environment.

    My code does not go against any SCSM database, but directly against the unsealed XML before you seal and import it. Please feel free to add any comments. Currently this code is stable for us and has saved me a lot of trouble fixing prefix ID's.

    This system isn't letting me have more than 3072 characters in this field, so the code will be posted in the next comment.

  • <#
    Patrick Major,
    Repair the management pack export file. Typically the export XML has some missing ID's (in certain action items) due to a MS SCSM bug

    This will add in the appropriate missing ID fields

    .PARAMETER XmlFileFullPath
    File path of the SCSM ManagementPack unsealed XML to be repaired

    PS C:\> Repair-ManagementPackExport managementpackName.xml


    If this file does not have strings requiring repair, then it will not be modified.


    function Repair-ManagementPackExport
    param ( [parameter(mandatory=$true)] [System.String] $xmlFileFullPath )

    # Select all nodes which contain a child path attribute that has a description, but does not contain a child path having an ID
    # note, special use of @ char, the last line with the "@ character must have no white space before it or the multiline string won't be recognized
    [string] $xPathExpression = @"
    Property[contains(@Path, "$Context/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Description$")] and
    not (Property[contains(@Path, "$Context/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Id$")])

    $ErrorActionPreference = "Stop"


    if (-not (Test-Path $XmlFileFullPath))
    $msg = "The file $XmlFileFullPath does not exist."
    throw [System.IO.FileNotFoundException] $msg

    $xmlFileFullPath = Resolve-Path -Path $xmlFileFullPath

    [Xml.XmlDocument] $xdoc = Get-Content $XmlFileFullPath
    [Xml.XmlNodeList] $nodes = $xdoc.SelectNodes($xPathExpression)

    if ($nodes -eq $null)
    Write-Host "No errors detected"

    [int] $nodeCount = $nodes.Count
    Write-Host "Starting Operation - Adding $nodeCount missing ID tags in XML"

    [Xml.XmlElement] $newNode = $null

    for ([int]$i=0; $i -lt $nodeCount; ++$i)

    $newNode = $xdoc.CreateElement('Property')
    $newNode.SetAttribute('Path', '$Context/Property[Type=''CustomSystem_WorkItem_Library!System.WorkItem'']/Id$')

    $newNode.InnerText = ''
    [Xml.XmlElement] $elementToInsertAfter = $null

    # check first to see if the activity type is defined at the higher level object. If it is, use this path since the children propty objects will only
    # contain generic system activity paths
    if ($nodes[$i].Path -ne $null)
    $newNode.InnerText = ReturnIDType $nodes[$i].Path

    # please see next comment for more code (again this field wasn't sufficient to fit the code required)

  • foreach ($propElement in $nodes[$i].Property)
    # only process if we haven't found the element to insert after
    if ($elementToInsertAfter -eq $null)
    # find the correct location to insert the new node (insert right below the ID node
    # this is being done because there are times when the objects that require this node insertion have nested objects. If the ID tag for the higher level object gets
    # inserted below the child object, it'll be considered invalid, so just safer to place around title

    if ($propElement.Path.Contains("`$Context/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Description$"))
    $elementToInsertAfter = $propElement

    # only process if we haven't yet found the activity type
    if ($newNode.InnerText -eq '')
    $newNode.InnerText = ReturnIDType $propElement.Path

    # we found all the info we need, break out early
    if ( ($newNode.InnerText -ne '') -and ($elementToInsertAfter -ne $null) )

    # the innerText is empty if we have a template without activities, in this case we do not need the ID
    if ($newNode.InnerText -ne '')

    if ($elementToInsertAfter -eq $null)
    throw "We have an issue with the XML formation. Expected Description tag is missing. Please review the Management pack file being submitted."

    $tmp = $nodes[$i].InsertAfter($newNode, $elementToInsertAfter);

    # we don't have a document encoding element, add one so that we don't lose character encoding
    if ($xdoc.DocumentElement.OwnerDocument.xml -eq $null)
    [Xml.XmlElement] $root = $xdoc.DocumentElement
    [Xml.XmlDeclaration] $xmldecl = $xdoc.CreateXmlDeclaration("1.0","UTF-16","")
    $tmp = $xdoc.InsertBefore($xmldecl, $root)

    Write-Host "Completed Operation - Added $nodeCount missing ID tags in XML."
    # Throwing an exception in this manner will actually bubble up to the Orchestrator runbook activity and give an error condition.
    Export-ModuleMember -Function Repair-ManagementPackExport

    # please see next comment for more code (again this field wasn't sufficient to fit the code required)

  • #region Private functions

    function ReturnIDType
    param ( [parameter(mandatory=$true)] [System.String] $pathText )

    # only load this settings object once (create a script level variable, acting like a static for this session)
    if ($script:activitySettingsObj -eq $null)
    $script:activitySettingsObj = Get-SCSMObject -Class (Get-SCSMClass -Id "5e04a50d-01d1-6fce-7946-15580aa8681d")

    [string] $retVal = ''

    if ($pathText.Contains("Microsoft.SystemCenter.Orchestrator.RunbookAutomationActivity"))
    $retVal = $script:activitySettingsObj.MicrosoftSystemCenterOrchestratorRunbookAutomationActivityBaseIdPrefix
    elseif ($pathText.Contains("System.WorkItem.Activity.ManualActivity"))
    $retVal = $script:activitySettingsObj.SystemWorkItemActivityManualActivityIdPrefix
    elseif ($pathText.Contains("System.WorkItem.Activity.ReviewActivity"))
    $retVal = $script:activitySettingsObj.SystemWorkItemActivityReviewActivityIdPrefix
    elseif ($pathText.Contains("System.WorkItem.Activity.ParallelActivity"))
    $retVal = $script:activitySettingsObj.SystemWorkItemActivityParallelActivityIdPrefix
    elseif ($pathText.Contains("System.WorkItem.Activity.SequentialActivity"))
    $retVal = $script:activitySettingsObj.SystemWorkItemActivitySequentialActivityIdPrefix
    elseif ($pathText.Contains("System.WorkItem.Activity.DependentActivity"))
    $retVal = $script:activitySettingsObj.SystemWorkItemActivityDependentActivityIdPrefix

    if ($retval -ne '') { $retVal += "{0}" }
    return $retVal