Delete Workitem or Activity from Portal
Best Answer
-
Davin_Clouthier Customer Adept IT Monkey ✭✭thanks for the reply Billy, that is an interesting idea I might have to try explore that avenue, for this solution to work I would probably have to find a way to hide the MA from view until the workflow could clean it up while also skipping the hidden activity so it would atleast go to the next while its pending deletion. I will post my solution if I find a way to do this. Any other suggestions or if anyone has hidden activties or anything would be a great help0
Answers
Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.Activity$) -Filter "DisplayName -eq MA544555" | Remove-SCSMObject -Force
Disclaimer - deleting work items is against ITIL best practices. It is recommended that you test this in a development environment before using it in production and make sure you have appropriate backups.
Actually this was a portal only feature, since we have dynamic change requests where our service owners can add tasks like project online (MA's from Commit) on the fly to build out there change, it is necessary to do this from the portal. The powershell options was apparent to me same as the runbook but when a service owner by accidently adds to many activities them waiting for a workflow to kick off or runbook is a very slow and undynamic solution so we avoided going down that path.
Current all RA's and MA's are added from portal tasks, so I'm trying to figure out if its possible to do any removals on accidental adds.
I'll have the webmaster remove the accepted answer. In the meantime, I spoke with one of our top consultants who informed me that the API will not accept deleting items and that you would probably have to use a webhook that's call PS from another server (or Azure). If it were me, i'd add a boolean extension to the Activity class and have a monitoring runbook that would run the deletion PS when the Boolean = true. Not what you were looking for, I know, but hopefully somebody else will have a better suggestion.
Thanks.
Davin's idea is a great one, and if you set the runbook up as a monitor for any updates to Manual Activities, it would be very quick in the deletion once the Activity was saved. I would bet within 60 seconds easy.