locked
How to send Review Activity notification linked with a Change Request. RRS feed

  • Question

  • Hi All,

    I want to create a notification for change management. The idea is whenever any "Activity Stage stauts "associated with Change requested is updated I want to send a notification E-mail that XYZ Change request has an activity and it is update. I tried to create such template but didn't find any way to associate a reference of Change Request ID with the activity.

    Please help.

    Regards/Anwar

    Monday, November 28, 2011 11:13 AM

Answers

  • Hi,

    things like that need so class extension and worklows with powershell.

    You can extend the Manual Activity Class with an Attribute like ParentWorkItemType. This Attribute need to be filled after creating it with an workflow. There for you can use a script in Powershell. The script musst reach the top of all work items so you don't use an PA or SA. 

    Guide for Workflows:

    https://marcelzehner.ch/2011/01/17/service-manager-workflows-part-1/

    And here is my script for the Workflow. This one is for Review Activity's. You can change it for every other Activity.

    $SMDefaultComputer = $env:computername
    $EventLogName = 'Service Manager'
    $EventLogSource = 'SetParentWorkItemRA'
    $count = 1
    do
    {
      $ErrorMessage = $null
      try
      {
        $RAClass = Get-SCClass -Name System.WorkItem.Activity.ReviewActivity
        $RA = Get-SCClassInstance -Class $RAClass -Filter "Id -eq $ra_id"
        $Relationship = Get-SCRelationship -Name System.WorkItemContainsActivity
        $RelationshipId = $Relationship.Id
        $RelationshipInstance = Get-SCRelationshipInstance -TargetInstance $RA |Where-Object -FilterScript {
          $_.RelationshipId -eq $RelationshipId
        }
        $Parent = $RelationshipInstance.SourceObject
        $Type = $Parent.Name.Substring(0,2)
        $ID = $Parent.Name
    
        if($Type -eq 'PA' -or $Type -eq 'SA')
        {
          while($Type -eq 'PA' -or $Type -eq 'SA')
          {
            $Activity = Get-SCClassInstance -Name $ID
            $RelationshipInstance2 = Get-SCRelationshipInstance -TargetInstance $Activity | Where-Object -FilterScript {
              $_.RelationshipId -eq $RelationshipId
            }
            $Parent2 = $RelationshipInstance2.SourceObject
            $Type = $Parent2.Name.Substring(0,2)
            $ID = $Parent2.Name
          }
          $RA.ParentWorkItemType = $Type
          $RA.ParentWorkItemID = $ID
          $RA | Update-SCClassInstance
          Write-EventLog -LogName $EventLogName -Source $EventLogSource -EntryType Information -EventId 42125 -Category 0 -Message "Die Manuelle Aktivitaet $ra_id wurde verarbeitet.$([Environment]::NewLine)ParentWorkItemType = $Type$([Environment]::NewLine)ParentWorkItemID = $ID$([Environment]::NewLine)Versuch $count"
        }
        else
        {
          $RA.ParentWorkItemType = $Type
          $RA.ParentWorkItemID = $ID
          $RA | Update-SCClassInstance
          Write-EventLog -LogName $EventLogName -Source $EventLogSource -EntryType Information -EventId 42125 -Category 0 -Message "Die Manuelle Aktivitaet $ra_id wurde verarbeitet.$([Environment]::NewLine)ParentWorkItemType = $Type$([Environment]::NewLine)ParentWorkItemID = $ID$([Environment]::NewLine)Versuch $count"
        }
      }
      Catch 
      {
        $ErrorMessage = $_.Exception.Message
        Write-EventLog -LogName $EventLogName -Source $EventLogSource -EntryType Warning -EventId 42126 -Message -Category 0 "Die Manuelle Aktivitaet $ra_id konnte nicht verarbeitet werden.$([Environment]::NewLine)Versuch $count$([Environment]::NewLine)$ErrorMessage"
      }
      $count++
      if($ErrorMessage -ne $null)
      {
        Start-Sleep -Milliseconds 200
      }    
    }
    until(($ErrorMessage -eq $null) -or ($count -ge '10'))
    if ($count -ge '10')
    {
      Write-EventLog -LogName $EventLogName -Source $EventLogSource -EntryType Error -EventId 42127 -Category 0 -Message "Der Change Request $cr_id konnte nicht verarbeitet werden.$([Environment]::NewLine)Versuch $count. Es wird nicht erneut versucht.$([Environment]::NewLine)$ErrorMessage"
    }

    After that you can create Queues Linke "MAs in CRs" with this Attribute. This Queue can be used in the Notifications. You can also use this Attribute for many other things. I also added the Attribute ParentWorkItemID for easily finding all Activity's from on CR oder SR.

    /Jana

    Wednesday, May 31, 2017 8:31 AM
  • This should be possible with an Orchestrator Runbook and PowerShell.

    My idea would be (raw idea and not tested)

    - Monitor on Activity Update

    - Get Object of updated Activity

    - Use PowerShell from here (Run .Net Script Activity):

    -- Get Related Work Item object of Activity (it might be needed to do this recursive if you have nested activities like parallel and/or sequential activities)

    -- If Related Work Item is a Change Request

    --- Get Related User of Change Request and his email address

    -- If Related Work Item is not a Change Request -> do nothing

    - Published Data of PowerShell (Run .Net Script Activity):

    -- Change Request details needed for notification

    -- Email address of User

    - Send Email Activity 

    Hope this helps.


    Andreas Baumgarten | H&D International Group

    Friday, May 12, 2017 6:20 AM

All replies

  • Hi Anwar,

    I'm not completely sure I understand your question, but have a look here for inspiration: http://blogs.technet.com/b/servicemanager/archive/2010/12/16/sending-notifications-when-a-reviewer-votes-on-a-review-activity.aspx
    And especially look at the first comment by Travis (the blog post author):
    Before somebody asks - no, sorry, it isnt possible to put properties of the parent review activity or change request into the notification template.  we have a DCR for R2 that we will try to get to that will enable this scenario.

    Does this answer your question? I have not tested this particular scenario in SCSM 2012 (formerly known as "R2") but there are definitely more substitution strings to choose from in SCSM2012 notification templates.

    /Per

    Monday, November 28, 2011 3:13 PM
  • Hi Per,

    Yes you have understood my requirement correctly. What I want is to associate Parent Work Item of any “Activity" in the activity update notification. But if this is not supported then it will be very difficult to associate activates with Change request, because user will not be able to know in notification send to them that this activity is related to XYZ change. Is there any other work around instead of upgrade to SCSM 2012.

    Regards,

    Anwar-

    Tuesday, November 29, 2011 5:39 AM
  • Hello,

    Is this function already available in SCSM?
    Still can't find the functionality,,
    Have tried the Monitor Object in Orchestrator but still not the solution.

    Can't find the solution on the internet.

    Regards,
    Wobbes.

    Wednesday, May 10, 2017 8:22 AM
  • Hi

    This functionality is not available out of the box and as a result we created the Xapity Notification Activity. This is a commercial product and you can download a 30 day full trial version from the link.

    The Notification Activity uses regular Service Manager notification templates, can add attachments, and sends to internal\external recipients.  Being able to place it in the SR\CR activity workflow means that you don't have to worry about trigger points or about timing issues with workflows. 

    Regards

    Glen


    Web: www.xapity.com  |   Twitter: @xapityapps  |   Facebook: xapityapps

    Wednesday, May 10, 2017 9:45 AM
  • This should be possible with an Orchestrator Runbook and PowerShell.

    My idea would be (raw idea and not tested)

    - Monitor on Activity Update

    - Get Object of updated Activity

    - Use PowerShell from here (Run .Net Script Activity):

    -- Get Related Work Item object of Activity (it might be needed to do this recursive if you have nested activities like parallel and/or sequential activities)

    -- If Related Work Item is a Change Request

    --- Get Related User of Change Request and his email address

    -- If Related Work Item is not a Change Request -> do nothing

    - Published Data of PowerShell (Run .Net Script Activity):

    -- Change Request details needed for notification

    -- Email address of User

    - Send Email Activity 

    Hope this helps.


    Andreas Baumgarten | H&D International Group

    Friday, May 12, 2017 6:20 AM
  • Hi,

    things like that need so class extension and worklows with powershell.

    You can extend the Manual Activity Class with an Attribute like ParentWorkItemType. This Attribute need to be filled after creating it with an workflow. There for you can use a script in Powershell. The script musst reach the top of all work items so you don't use an PA or SA. 

    Guide for Workflows:

    https://marcelzehner.ch/2011/01/17/service-manager-workflows-part-1/

    And here is my script for the Workflow. This one is for Review Activity's. You can change it for every other Activity.

    $SMDefaultComputer = $env:computername
    $EventLogName = 'Service Manager'
    $EventLogSource = 'SetParentWorkItemRA'
    $count = 1
    do
    {
      $ErrorMessage = $null
      try
      {
        $RAClass = Get-SCClass -Name System.WorkItem.Activity.ReviewActivity
        $RA = Get-SCClassInstance -Class $RAClass -Filter "Id -eq $ra_id"
        $Relationship = Get-SCRelationship -Name System.WorkItemContainsActivity
        $RelationshipId = $Relationship.Id
        $RelationshipInstance = Get-SCRelationshipInstance -TargetInstance $RA |Where-Object -FilterScript {
          $_.RelationshipId -eq $RelationshipId
        }
        $Parent = $RelationshipInstance.SourceObject
        $Type = $Parent.Name.Substring(0,2)
        $ID = $Parent.Name
    
        if($Type -eq 'PA' -or $Type -eq 'SA')
        {
          while($Type -eq 'PA' -or $Type -eq 'SA')
          {
            $Activity = Get-SCClassInstance -Name $ID
            $RelationshipInstance2 = Get-SCRelationshipInstance -TargetInstance $Activity | Where-Object -FilterScript {
              $_.RelationshipId -eq $RelationshipId
            }
            $Parent2 = $RelationshipInstance2.SourceObject
            $Type = $Parent2.Name.Substring(0,2)
            $ID = $Parent2.Name
          }
          $RA.ParentWorkItemType = $Type
          $RA.ParentWorkItemID = $ID
          $RA | Update-SCClassInstance
          Write-EventLog -LogName $EventLogName -Source $EventLogSource -EntryType Information -EventId 42125 -Category 0 -Message "Die Manuelle Aktivitaet $ra_id wurde verarbeitet.$([Environment]::NewLine)ParentWorkItemType = $Type$([Environment]::NewLine)ParentWorkItemID = $ID$([Environment]::NewLine)Versuch $count"
        }
        else
        {
          $RA.ParentWorkItemType = $Type
          $RA.ParentWorkItemID = $ID
          $RA | Update-SCClassInstance
          Write-EventLog -LogName $EventLogName -Source $EventLogSource -EntryType Information -EventId 42125 -Category 0 -Message "Die Manuelle Aktivitaet $ra_id wurde verarbeitet.$([Environment]::NewLine)ParentWorkItemType = $Type$([Environment]::NewLine)ParentWorkItemID = $ID$([Environment]::NewLine)Versuch $count"
        }
      }
      Catch 
      {
        $ErrorMessage = $_.Exception.Message
        Write-EventLog -LogName $EventLogName -Source $EventLogSource -EntryType Warning -EventId 42126 -Message -Category 0 "Die Manuelle Aktivitaet $ra_id konnte nicht verarbeitet werden.$([Environment]::NewLine)Versuch $count$([Environment]::NewLine)$ErrorMessage"
      }
      $count++
      if($ErrorMessage -ne $null)
      {
        Start-Sleep -Milliseconds 200
      }    
    }
    until(($ErrorMessage -eq $null) -or ($count -ge '10'))
    if ($count -ge '10')
    {
      Write-EventLog -LogName $EventLogName -Source $EventLogSource -EntryType Error -EventId 42127 -Category 0 -Message "Der Change Request $cr_id konnte nicht verarbeitet werden.$([Environment]::NewLine)Versuch $count. Es wird nicht erneut versucht.$([Environment]::NewLine)$ErrorMessage"
    }

    After that you can create Queues Linke "MAs in CRs" with this Attribute. This Queue can be used in the Notifications. You can also use this Attribute for many other things. I also added the Attribute ParentWorkItemID for easily finding all Activity's from on CR oder SR.

    /Jana

    Wednesday, May 31, 2017 8:31 AM