locked
Generating Activity Titles from Parent Service Request RRS feed

  • Question

  • We are trying to setup a new SCSM 2012 system, and are having concern over all the titles for the child activities that are generated for the Service Request template we are testing with.  We have figured out how to allow the affected User to enter a custom title into their SR, but then all the child activities that spawn off that SR have static titles, all pulling from the activity template. 

    A good example of our concern is the associate that will be a "reviewer".  I am the test reviewer right now, and my "activity" queue has 50 activities all with the same title.  We find this almost useless from a reviewer standpoint if they want to use the SCSM console.

    So my question is, can I set the activity to pull its title from the parent SR?  I would love to have something like "Service Request Approval - [variable]".

    Any help would be very appreciated

    Mark


    Mark

    Friday, November 30, 2012 9:46 PM

Answers

  • Hey Mark,

    Unfortunately that's not possible out of box. You would either have to create a custom PowerShell workflow within SCSM or create a Runbook which polls the parent work item information and replaces the child activity titles with the parent one's. It's not very difficult to get this job done, but as you suggested, it would be quite nice to configure 'inheritance'  directly within SCSM.

    Cheers

    Alex

    • Marked as answer by Marcel Zehner Sunday, December 2, 2012 7:59 PM
    Saturday, December 1, 2012 12:41 AM

All replies

  • Hey Mark,

    Unfortunately that's not possible out of box. You would either have to create a custom PowerShell workflow within SCSM or create a Runbook which polls the parent work item information and replaces the child activity titles with the parent one's. It's not very difficult to get this job done, but as you suggested, it would be quite nice to configure 'inheritance'  directly within SCSM.

    Cheers

    Alex

    • Marked as answer by Marcel Zehner Sunday, December 2, 2012 7:59 PM
    Saturday, December 1, 2012 12:41 AM
  • I'm not familiar with Powershell, are there samples of codes or link(s) to review the syntax to perform this? 
    Tuesday, December 4, 2012 10:20 PM
  • Here would be an example I've quickly created (with comments for each command withing the script :-))

    import-module smlets
    
    $SRClass = get-scsmclass -name System.WorkItem.ServiceRequest$ # get the Service Request class - required for the get-scsmobject cmdlet
    
    $SR = get-scsmobject -class $SRClass -Filter "ID -eq INSERT_SR_ID_HERE" # get the SR object to identify its contained activities
    $AllSRActivities = get-scsmrelatedobject -SMObject $SR -Relationship $WIContainsActivityRel # get all activities contained by the SR
    
    $MActivities = $AllSRActivities | where {$_.ClassName -eq "System.WorkItem.Activity.ManualActivity"} # separate all MAs in a dedicated variable
    $RActivities = $AllSRActivities | where {$_.ClassName -eq "System.WorkItem.Activity.ReviewActivity"} # separate all RAs in a dedicated variable
    
    $SRID = ($SR).ID # save SR ID in a dedicated variable
    $SRTitle = ($SR).Title # save SR Title in a dedicated variable
    
    
    if ($MActivities -ne $null) # script only enters the if clause if at least 1 Manual Activity was found
    {
    	foreach ($MA in $MActivities) # foreach loop here to ensure the title gets set for all MAs if more than 1
    	{
    	
    	$MA | set-scsmobject -Property Title -Value "Manual Activity for SR with ID $SRID and Title: $SRTitle" # this commands sets effictivly the title of the Manual Activity, the title can be modified as required
    
    	}
    }
    
    
    if ($RActivities -ne $null) # script only enters the if clause if at least 1 Review Activity was found
    {
    
    	foreach ($RA in $RActivities) # foreach loop here to ensure the title gets set for all RAs if more than 1
    	{
    
    	$RA | set-scsmobject -Property Title -Value "Review Activity for SR with ID $SRID and Title: $SRTitle" # this commands sets effictivly the title of the Review Activity, the title can be modified as required
    
    	}
    }
    
    remove-module smlets

    The same script works with Change Requests, but you have to change the class then in the script to point to System.WorkItem.ChangeRequest

    Regarding the Service Request ID, this ID needs to be inserted dynamically. If you create a workflow in SCSM which executes this script, you have to "subscribe" the SR ID in the script properties. See also this blogpost for detailed information: http://blogs.technet.com/b/servicemanager/archive/2011/03/15/updating-a-change-request-when-activities-are-updated-using-powershell-in-a-workflow.aspx

    Good luck!

    Cheers

    Alex

    Wednesday, December 5, 2012 8:02 AM
  • Just fyi, Alex, you didn't assign $WIContainsActivityRel in your script :)

    You should also consider nested activities. For example, if a review activity is nested in a parallel or sequential activity, your script should be able to find them and modify those as well.

    We did something similar where we surfaced a root parent work item's title in the activity view..one technique we used was a custom workflow to update the activity with the parent root work item's title (like you suggested :) ). We also wrote a custom control that the view used to retrieve the root parent work item's title and display it directly in the view (but that can be really bad for performance)

    Wednesday, December 5, 2012 8:39 PM