Can you create a service request from another service request activity
Best Answer
-
Brian_Wiest Customer Super IT Monkey ✭✭✭✭✭We have this setup for one of our support groups.
Creates a new SR via PowerShell Activity.
Note make sure the first SR with the P$A has other activities so this do not auto complete.Param([guid]$WorkItemID) import-module smlets #Get the Service Request Class $serviceRequestClass = Get-SCSMClass -name System.WorkItem.ServiceRequest$ $serviceRequestPriority = Get-SCSMEnumeration -Name ServiceRequestPriorityEnum.Low $serviceRequestUrgency = Get-SCSMEnumeration -Name ServiceRequestUrgencyEnum.Low $Object = Get-SCSMObject -Class $serviceRequestClass -Filter "ID -eq '$WorkItemID'" Write-Output $WorkItemID Write-Output $Object.Title $affectedUserRelClass = Get-SCSMRelationshipClass System.WorkItemAffectedUser$ $affectedUser = Get-SCSMRelatedObject -SMObject $Object -Relationship $AffectedUserRelClass $SRHashTable = @{ Title = "New User " + $Object.Title; Description = $Object.Description; ID = "SR{0}"; Urgency = $serviceRequestUrgency; Priority = $serviceRequestPriority; } #Create initial Service Request $newServiceRequest = New-SCSMOBject -Class $serviceRequestClass -PropertyHashtable $SRHashTable -PassThru $serviceRequestId = $newServiceRequest.ID #Get The Service Request Type Projection $serviceRequestTypeProjection = Get-SCSMTypeProjection -name System.WorkItem.ServiceRequestProjection$ #Get the Service Request created earlier in a form where we can apply the template $serviceRequestProjection = Get-SCSMObjectProjection -ProjectionName $serviceRequestTypeProjection.Name -filter “ID -eq $serviceRequestId” #Get The Service Request Template $serviceRequestTemplate = Get-SCSMObjectTemplate -DisplayName “New User SR” #Apply the template to the Service Request Set-SCSMObjectTemplate -Projection $serviceRequestProjection -Template $serviceRequestTemplate #Set affected user $AffectedUserRel = get-scsmrelationshipclass -name System.WorkItemAffectedUser$ New-SCSMRelationshipObject -Relationship $AffectedUserRel -Source $newServiceRequest -Target $affectedUser -Bulk $RWIClass = Get-SCSMRelationshipClass -Name System.WorkItemRelatesToWorkItem$ New-SCSMRelationshipObject -Relationship $RWIClass -Source $Object -Target $newServiceRequest -Bulk New-SCSMRelationshipObject -Relationship $RWIClass -Source $newServiceRequest -Target $Object -Bulk Remove-Module SMlets
Just update you SR Template title to meet your environment.3
Answers
Thereby creating a new SR with the option of setting multiple properties through the property hashtable. You could also apply a template, etc.
Creates a new SR via PowerShell Activity.
Note make sure the first SR with the P$A has other activities so this do not auto complete.
Just update you SR Template title to meet your environment.
Added now:
https://community.cireson.com/categories/powershell