Home Orchestrator

how to automatically set "assigned user"-field to user who closed workitem, if field is empty?

Silas_SulserSilas_Sulser Customer Advanced IT Monkey ✭✭✭

Hi guys

We are pretty new to Orchestrator but we already love it. :)

We often have situations where somebody closes a workitem but don't assign it to itself (a lot of BMC Remedy users).

So the workitem is closed but the "assigned user"- field is still empty what is not nice.

How can we achieve that by using Orchestrator runbooks?

I guess it's something like setting a trigger to "closing a workitem" or similar and update the assigned user field with the person who closed it, right?

Thanks and best regards


Best Answer


  • Eric_KrasnerEric_Krasner Customer Advanced IT Monkey ✭✭✭
    Option 2 is a better option, we use it all the time.  Monitor runbooks have an uncanny habit of getting stopped and not restarted.  Adding a Runbook Automation Activity to your template is more failsafe.
  • Silas_SulserSilas_Sulser Customer Advanced IT Monkey ✭✭✭
    Many thanks Adam I'm gonna check that out!
    For everyone who's interested, here's a PS Script what does the same for SRs:
    # The multiple Criteria part modified from  http://www.lazywinadmin.com/2016/03/powershellscsm-get-manual-activities.html
    # Import Smlets Module
    Import-module -name Smlets
    # Get the Service Request Class
    $SRClass = Get-SCSMClass -Name System.WorkItem.ServiceRequest$
    # Get the Service Request Completed Status Enumeration
    $SRStatusClosed = Get-SCSMEnumeration -Name ServiceRequestStatusEnum.Closed$
    # Get the starting date from where we are searching
    $SRClosedDay = (Get-date).Adddays(-1)
    # Get the Criteria Class
    $CriteriaClass = "Microsoft.EnterpriseManagement.Common.EnterpriseManagementObjectCriteria"
    # Define the Filter
    $Filter = "Status = '$($SRStatusClosed.Id)' AND ClosedDate > '$SRClosedDay'"
    # Create the Criteria Object
    $CriteriaObject = new-object $CriteriaClass $Filter, $SRClass
    # Collect all Closed Service Requests in the last day
    $Workitems = Get-SCSMObject -criteria $CriteriaObject
    $AssignedToUserRel = Get-SCSMRelationshipClass -Name System.WorkItemAssignedToUser
    $ClosedByUserRel = Get-SCSMRelationshipClass -Name System.WorkItemClosedByUser
    #Loop through each Service Request checking the Assigned To and Closed To values
    ForEach ($SR in $Workitems)
           $AssignedTo = Get-SCSMRelatedObject -Relationship $AssignedToUserRel -SMObject $SR
           Write-Host "$AssignedTo"
           $ClosedBy = Get-SCSMRelatedObject -Relationship $ClosedByUserRel -SMObject $SR
            Write-Host "$ClosedBy"
           If ($AssignedTo -ne $ClosedBy) 
             {New-SCSMRelationshipObject -Relationship $AssignedToUserRel -Source $SR -Target $ClosedBy  -Bulk }
      } #End ForEach loop

Sign In or Register to comment.