Home Service Manager

Seeing 'Blank' Reviewers in Review Activities

Tony_CollettTony_Collett Cireson Support Super IT Monkey ✭✭✭✭✭
Occasionally if a review activity isn't populated with an approver and it is set to In Progress, SCSM automatically populates the activity with a 'blank' reviewer. 

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

Answers

  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    Hi Tony,
    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
  • L_SchickL_Schick Member Advanced IT Monkey ✭✭✭

    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

  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭
    I have a script to get all RAs In Progress with no reviewers and show the parent WI, but if I'm not mistaken you're actually referring to an empty object is actually in the list of reviewers right? Something you can click on in the list, but is not defined whatsoever?

    If not I'll post the PowerShell!
  • Tony_CollettTony_Collett Cireson Support Super IT Monkey ✭✭✭✭✭
    Thanks for the responses. To clarify, I'll show you an image of what I'm talking about: http://imgur.com/rf7r8o2

    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. 

  • seth_coussensseth_coussens Member Ninja IT Monkey ✭✭✭✭
    That script should do it for you...
  • Tony_CollettTony_Collett Cireson Support Super IT Monkey ✭✭✭✭✭
    I've been able to find them with an Advanced Search for the criteria:
    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!
  • Candice_YeudallCandice_Yeudall Customer Advanced IT Monkey ✭✭✭
    Every review activity that we add gets that, but I guess that would because the default change request automatically creates a Review activity, it is really annoying for our people to have to go in and change it every time. BTW this happens in both the console and portal so it is something with in SCSM itself.
  • Narmin_HemnaniNarmin_Hemnani Customer IT Monkey ✭

    How do I get the parentID from the Review Activity.

    Following is working but missing parentID?

    Smlets Module

    Import-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$
    $RAStatusCompleted = Get-SCSMEnumeration -Name ActivityStatusEnum.Completed$

    Capture the date from where we are searching

    $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'"
    #$Filter = "Status = '$($RAStatusCompleted.Id)' AND LastModified > '$RAModifiedDay'"
    $Filter = "LastModified > '$RAModifiedDay'"

    Create the Criteria Object

    $CriteriaObject = new-object $CriteriaClass $Filter,$RAClass

    Get the Reviewer relationship classes

    $RAHasReviewerClass = Get-SCSMRelationshipClass System.ReviewActivityHasReviewer$
    $ReviewerIsUserClass = Get-SCSMRelationshipClass System.ReviewerIsUser$

    Get the RA rejected in the last 3 days

    Get-SCSMObject -criteria $CriteriaObject |
    ForEach-Object -Process {

    Current Review Activity

    $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

    # Create a new PowerShell Object
    [pscustomobject][ordered]@{
    ReviewActivityName = $RA.Name
    #ReviewActivityTitle = $RA.Title
    #Comments = $item.comments -as [string]
    ReviewerDisplayName = $ReviewerObj.displayname
    ReviewActivityTitle = $RA.Title
    # ReviewActivityCreated = $ReviewerObj.date
    # Decision = $item.decision.displayname
    # Comments = $item.comments -as [string]
    #ReviewActivityCreated =$RA.CreatedDate
    #ReviewActivityStatus =$Ra.Status


    }

    }

    }#| Format-List

  • Geoff_RossGeoff_Ross Cireson Consultant O.G.

    Hi @Narmin_Hemnani

    Try the following function

    #Function to get the top Parent WI of an activity
    Function Get-ParentWI {
        Param (
            $Activity,
            [string]$ComputerName
        )
        
        $SCSM = @{
            ComputerName = $ComputerName
        }
        
        #Get Parent of this Activity
        $WIContainsActivityRel = Get-SCSMRelationshipClass "System.WorkItemContainsActivity" @SCSM
        $ParentWI = (Get-SCSMRelationshipObject -TargetObject $Activity -TargetRelationship $WIContainsActivityRel @SCSM).SourceObject
        
        If ($ParentWI -eq $null) {
            # We've reached the top - Return Original Actvity
            Return $Activity
        }
        Else {
            # Parent is not confrmed as the root, and thus, we will loop into another "Get-ParentWI" function.
            Get-ParentWI -Activity $ParentWI @SCSM
        }
    }
    

    Then you can use it with

    $ParentWI = Get-ParentWI -Activity $RA -ComputerName "SCSMSERVER1"
    

    Geoff

  • Narmin_HemnaniNarmin_Hemnani Customer IT Monkey ✭

    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

  • Geoff_RossGeoff_Ross Cireson Consultant O.G.

    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

    Parent = $ParentWI.Id
    

    Into the creation of the custom PS Object.

    Geoff

Sign In or Register to comment.