How to clear pending Service request's manual or review activities from a Failed Service request
Best Answers
-
Justin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭Hey David,
This should set the status of all 'Pending' activities in 'Failed' SRs to the status of 'Cancelled.'<div>$failedStatus = Get-SCSMEnumeration -Name ServiceRequestStatusEnum.Failed </div><div>$SR = Get-SCSMObject -Class (Get-SCSMClass -name System.WorkItem.ServiceRequest$) -Filter "Status -eq $($failedStatus.id)" </div><div><br></div><div>foreach ($s in $SR) {</div><div> $ro = Get-SCSMRelatedObject -SMObject $s -Relationship (Get-SCSMRelationshipClass -Name system.workitemcontainsactivity) </div><div> foreach ($r in $ro) { </div><div> if ($r.status.DisplayName -eq 'Failed') { </div><div> $r | Set-SCSMObject -Property Status -Value Cancelled </div><div> }</div><div> }</div><div>}</div>
Hope this helps!5 -
Justin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭Formatting got weird on that...but it should still work.
5 -
Conner_Wood Customer Ninja IT Monkey ✭✭✭✭You could also potentially compare if the current activity is sequential or parallel and check for activities within those.... assuming cancelling a sequential/parallel activity doesn't automatically cancel the activities itself contains.
I recommend looking at my SCSM CopyCat Source Code, as it has the ability to close a SR and close all activities. I believe I had to deal with that....
5 -
Justin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭Hey David,
If that script gets your activities fixed up could you mark that post as the answer please?
5 -
Marek_Lefek Customer Advanced IT Monkey ✭✭✭@Justin_Workman is there a possibility to run workflow that close the SR where activities are cancelled? There is option i menu to closed the SR and nedd to closed by PS.
1 -
Konstantin_Slavin-Bo Customer Ninja IT Monkey ✭✭✭✭Thomas describes here, how to create a workflow, which cancels activities when a SR fails: https://blogs.technet.microsoft.com/thomase/2013/07/30/cancel-pending-activities-in-a-failed-service-request/
2
Answers
This should set the status of all 'Pending' activities in 'Failed' SRs to the status of 'Cancelled.'
I recommend looking at my SCSM CopyCat Source Code, as it has the ability to close a SR and close all activities. I believe I had to deal with that....
If that script gets your activities fixed up could you mark that post as the answer please?
So you use Thomas workflow?
From your practise, what status value should be set for Activities and SR when SR is failed or cancelled?
Im asking according to Dashboard results, where in default report of Active MA shows MA in status "Cancelled", "Skipped" also when they are in SR with status "Closed".
And also in "Failed" are not closed automaticly and activities are shown in Analitycs list
I don't know about Cirons AutoClose (we don't use it because it can't take holidays and weekends into account), but by default, all pending activities are left in the pending state, when a SR fails or is cancelled.
We set all pending activities to cancelled, when a SR is failed or cancelled.
I checked, and the default query for Current > Manual Activity dashboard only excludes Failed and Completed activities. I can help you rewrite the query, so it excludes more statuses, if you want? Which MA statuses do you want the dashboard to include in the count?
- Completed
- Cancelled
- Skipped
- In Progress
- On Hold
- Failed
- Rerun
- Pending
My immediate thought would be to only show In Progress, Pending and maybe Rerun? What about On Hold?In portal Settings > DashBoard Query Settings, I change source called "Active Manual Activities By Category". This works for Cireson Analitycs but don't works for Cireson Dashoboard.
In the source I change one line where I add 2 more exclusion. This appear in 2 places in those query. Full query in attachement:
Default version:
Chenge for:
Below I listed StatusID from list "ActivityStatusEnum" :
Yeah, analytics and dashboard are using different queries. I looked into it, and the query doesn't have a title, but you should be able to find the query for Manual Activity Dashboard by sorting the view by Query Ascending, and it should then be the 8th query, beginning with
IF(@UserId IS NULL) BEGIN SELECT ds.DisplayString Tier, count(*) Active....
The structure of the query is almost identical to the corresponding analytics query, so you should be able to add the status id's in the same manner.
This is only going to get Failed activities inside Closed SRs. From my original description above it looks like I meant to target 'Pending' activities and set them as cancelled, but the script actually targets 'Failed' activities. If you're looking for Failed activities in Closed SRs, this will do it. If you want to adjust the activity status being targeted you can change the 'Failed' to whatever status you want.