Seeing 'Blank' Reviewers in Review Activities
Is there any way to see (either with Powershell or a good advanced search filter) all of the requests that have this blank approver where the RA is In Progress?
Thanks
Best Answer
-
Adam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭Here's a start in that case:
$raInProgressStatus = (Get-SCSMEnumeration ActivityStatusEnum.Active$).Id
$raClass = Get-SCSMClass System.WorkItem.Activity.ReviewActivity$
$reviewActivities = Get-SCSMObject (Get-SCSMClass System.WorkItem.Activity.ReviewActivity$) -Filter "Status -eq $raInProgressStatus"
$raReviewerRelClass = Get-SCSMRelationshipClass System.ReviewActivityHasReviewer$
$raReviewerIsUserRelClass = Get-SCSMRelationshipClass System.ReviewerIsUser$
foreach ($ra in $reviewActivities)
{
$reviewActivity = Get-SCSMObject $raClass -Filter "Id -eq $ra"
#reviewers
try
{
$reviewers = Get-SCSMRelatedObject -SMObject $reviewActivity -Relationship $raReviewerRelClass
}
#no reviewers
catch
{
$parentWI = Get-SCSMRelationshipObject -ByTarget $ra
write-host $ra.id "has no reviewers for" $parentWI.SourceObject.Name
}
}6
Answers
I've not seen this behaviour but will try and replicate it later as I'm intrigued.
As for the PowerShell its totally possible but gets a bit complex as linking a User to an RA as a reviewer is a 2 step process programmatically. an RA Object is related to a Reviewer Object with a relationship of class System.ReviewActivityHasReviewer and then the Review is related to the User with the class of System.ReviewerIsUser.
So you need to get all RAs In Progress, and for each, find the Reviewer object related with System.ReviewActivityHasReviewer. If it has one, you need to check if there is a User related with System.ReviewerIsUser and if there isn't, then this situation has occurred. Add this RA to an array and continue looping. At the end of the loop, the array will contain all the RAs with a blank approver.
Hope this helps, let me know if you need any more help turning the pseudo code into PowerShell.
Geoff
I found this link which has a powershell script that may help
http://model-technology.com/scsm-script-remove-unassigned-reviewer-instances/
Otherwise if you use Orchestrator you can get all in progress review activities -> get related reviewers -> Then get AD Users or Groups where the "Relationship Class" does not equal "Is User" and dump that to a list. This should give you all the related reviewers that are not User or Group objects
If not I'll post the PowerShell!
This happens when a Review activity goes from Pending to In Progress and doesn't have a reviewer beforehand.
I would like to be able to find all the reviewers where the name is blank. Only need to print out a list at this stage. I'll have a look at creating a Runbook that does that - thanks L_Schick.
$raInProgressStatus = (Get-SCSMEnumeration ActivityStatusEnum.Active$).Id
$raClass = Get-SCSMClass System.WorkItem.Activity.ReviewActivity$
$reviewActivities = Get-SCSMObject (Get-SCSMClass System.WorkItem.Activity.ReviewActivity$) -Filter "Status -eq $raInProgressStatus"
$raReviewerRelClass = Get-SCSMRelationshipClass System.ReviewActivityHasReviewer$
$raReviewerIsUserRelClass = Get-SCSMRelationshipClass System.ReviewerIsUser$
foreach ($ra in $reviewActivities)
{
$reviewActivity = Get-SCSMObject $raClass -Filter "Id -eq $ra"
#reviewers
try
{
$reviewers = Get-SCSMRelatedObject -SMObject $reviewActivity -Relationship $raReviewerRelClass
}
#no reviewers
catch
{
$parentWI = Get-SCSMRelationshipObject -ByTarget $ra
write-host $ra.id "has no reviewers for" $parentWI.SourceObject.Name
}
}
RA = In Progress AND Reviewer > Is User > Display Name is Empty.
I tested the script provided by Adam, and it seems to display All RAs In Progress. I didn't have time to modify it to include the empty Reviewer object.
Thanks!
How do I get the parentID from the Review Activity.
Following is working but missing parentID?
Smlets ModuleImport-module -name smlets
#Read more: https://www.sharepointdiary.com/2021/08/powershell-out-file.html#ixzz8cykR92e5
#Read more: https://www.sharepointdiary.com/2021/08/powershell-out-file.html#ixzz8cykR92e5
#Read more: https://www.sharepointdiary.com/2021/08/powershell-out-file.html#ixzz8cyjxH1t4
Capture the SR Failed Status#$RAStatusFailed = Get-SCSMEnumeration -Name ActivityStatusEnum.Failed$
Capture the date from where we are searching$RAStatusCompleted = Get-SCSMEnumeration -Name ActivityStatusEnum.Completed$
$RAModifiedDay = (get-date).Adddays(-3)
Get the Manual Activity Class$RAClass = Get-SCSMClass -Name System.WorkItem.Activity.ReviewActivity$
Get the Criteria Class$CriteriaClass = “Microsoft.EnterpriseManagement.Common.EnterpriseManagementObjectCriteria”
Define the filter#$Filter = "Status = '$($RAStatusFailed.Id)' AND LastModified > '$RAModifiedDay'"
Create the Criteria Object#$Filter = "Status = '$($RAStatusCompleted.Id)' AND LastModified > '$RAModifiedDay'"
$Filter = "LastModified > '$RAModifiedDay'"
$CriteriaObject = new-object $CriteriaClass $Filter,$RAClass
Get the Reviewer relationship classes$RAHasReviewerClass = Get-SCSMRelationshipClass System.ReviewActivityHasReviewer$
Get the RA rejected in the last 3 days$ReviewerIsUserClass = Get-SCSMRelationshipClass System.ReviewerIsUser$
Get-SCSMObject -criteria $CriteriaObject |
Current Review ActivityForEach-Object -Process {
$RA = $_
Get the rejected review(s) on this RA$RejectedReview = Get-SCSMRelatedObject -SMObject $RA -Relationship $RAHasReviewerClass
| Where {$_.decision.displayname -eq 'Rejected'}foreach ($item in $RejectedReview)
{
# Get the reviewer information
$ReviewerObj = Get-SCSMRelatedObject -SMObject $Item -Relationship $ReviewerIsUserClass
}
}#| Format-List
Hi @Narmin_Hemnani
Try the following function
Then you can use it with
Geoff
No that statement doesnt get the parentid. The script that I provided without any errors. Can you please firsr run it and then add your suggestion, that would help so see what other changes need to be made.
Thank you
Hi @Narmin_Hemnani
My function gets the whole Top Level Parent object, given a Activity.
Its a recursive function so will get the top level parent, even if the provided activity is nested under sequential / parallel activities.
Add the function at the very top if your code and then add call to it within the ForEach-Object loop. Its gets the whole Parent so you then need to add
Into the creation of the custom PS Object.
Geoff