SCSM Program - Reassign Incident Support Group Based On Assigned To
In particular, when Searching and Retrieving Results from a Type Projection using the SCSM C# SDK, it's really hard and there's tons of small issues that make it feel impossible.
The issue I encountered was the fact the "Simple Expression" couldn't handle GUIDs and instead I found I had to use the "In". I did post about this earlier on the technet forums, but I figure it wouldn't hurt to post the answer here as well.
return @"<Criteria xmlns='http://Microsoft.EnterpriseManagement.Core.Criteria/'><Reference Id='" + workItemMP.Name + @"' PublicKeyToken='" + workItemMP.KeyToken + @"' Version='" + workItemMP.Version.ToString() + @"' Alias='WorkItem' /> <Reference Id='" + coreIRMP.Name + @"' PublicKeyToken='" + coreIRMP.KeyToken + @"' Version='" + coreIRMP.Version.ToString() + @"' Alias='Incident' /> <Expression> <In>" + "<GenericProperty Path=\"$Context/Path[Relationship='WorkItem!System.WorkItemAssignedToUser']$\">Id</GenericProperty>" + @"<Values> <Value>" + "{" + str_scsmUserGUID + "}" + @"</Value> </Values> </In> </Expression> </Criteria>";
Again, Feel free to download and check out the C# Source Code that is included with the program!
Comments
If someone ever needed to tweak the program for Service Requests, they'd mainly need to change some key string values from Incident to Service Request:
This is mainly because the Assigned To Relationship is a WorkItem relationship, so both IR and SR reference the same thing because they extend from WorkItem which means less things to tweak.