AdhocAdam / smletsexchangeconnector

SMLets PowerShell based Exchange Connector for controlling Microsoft System Center Service Manager 2016+
https://adhocadam.github.io/smletsexchangeconnector/
GNU General Public License v3.0
29 stars 19 forks source link

Resolved by User Relationship is not deleted when undo-workitemresolution is called #466

Closed SimonZein closed 1 year ago

SimonZein commented 1 year ago

Describe the bug When the undo-workitemresolution function is called, the resolved by user relationship is still present on the workitem

Help us reproduce the bug Version of the connector you are using:5.0.3

Expected behavior The Resolved By User Relationship should be deleted as well

Location and Environment Where are you running this from? : Workflow What SCSM version are you running? (i.e. 2012R2, 2016, 2016 UR3, 1801, etc.): 2019

The function does not have any code where the relationship gets deleted. SO maybe "bug" is not correct here.

I added the following code to the customevents "Invoke-AfterReactivate" function

if($workItem.ClassName -in 'System.WorkItem.Incident','System.WorkItem.Problem') { $resbyUserObject = Get-SCSMRelationshipObject -BySource $workItem -Filter "RelationshipId -eq '$($workResolvedByUserRelClass.Id)'" @scsmMGMTParams if($resbyUserObject) { try { remove-scsmrelationshipobject -SMObject $resbyUserObject } catch { $logMessage = $_.Exception.Message New-SMEXCOEvent -Source "CustomEvents" -EventId 25 -LogMessage $logMessage -Severity "Warning" } } }

but imo this would be fine for the base connector

AdhocAdam commented 1 year ago

Resync your branches and Pull Request it up!

AdhocAdam commented 1 year ago

Will ship via #468