Limit incident status to user groups in #servicemanager


This week I had an interesting demand by one of our clients. They had a custom incident workflow with custom incident status fields ( like example status1, status2, … ).

They wanted to have a set of 3 user groups to be able to set a specific status :
Example :

Group1 can set Status from Active -> Open

Group2 can set Status from <All> -> Closed

Group3 can set Status from Resolved -> Closed

You understand where I’am going to. Now apparently this was not possible out-of-the-box. Let’s go through the steps :

  1. Create a powershell script that can be used to set the correct status and contain the logic required for the status changes.

    I created this script as an example. The script will set the status if the current incident to “Active” only if the previous state was “Closed”. If another previous status was found that the script will not reset the status. Now this is just an example that can certainly be extended.

    The script look like this :


    import-module smlets

    $PropertyHash = @{“Status” = $Status}

    $class = get-scsmclass -name system.workitem.incident$

    $Selection = Get-SCSMObject -Class $class -Filter “ID -eq $id”

    # Add conditions to status

    If ( $Status -eq “Active” -AND $Selection.Status -match “Closed” ) {

    $Selection | Set-SCSMObject -PropertyHashtable $PropertyHash

    write-host “Status set to $Status” }

    else { write-host “Status change to Active only allowed From Closed State” }

    Now let’s go through the script.

    The script performs the following actions :

    Define 2 parameters : the required status and the Incident ID.

    Import the module for using the service manager cmdlets.

    Get the classname for the incident class.

    Get the service manager incident object that has the ID of the selected record.

    Add if clause : If the required status is “Active” and the previous Status is “Closed” then the incident can be reset the Active. If not a message is logged and nog changes are created.

    You can test the script manually in order to verify the correct functioning. Just add a state and use an existing incident ID. Attention ! This is the ID in the form of IDXXX not the internal ID ( GUID ) of the workitem.
    Okay Step 2.

  2. Create and additional task in order to run the script to set the correct status.

Add a task that performs the following actions :

The task will perform the following command:


With the following parameters :

-file “c:\program files\sc\scripts\sc_status.ps1” “Active” + the property for the ID of the incident.

Just use the insert property button for the id.

Okay last step.

  1. Create a custom user role

    Now just add an additional user role ( incident resolvers ) and limit the actions that the user role can access. Just remove the traditional buttons :

  • Change incident status
  • Resolve
  • Close

    And add access to the newly created task.

    Add a user and test.

    It’s looks like this :
    The user only has access to the custom task in order to set the status of an incident. If the incident status is not “Closed” and the Set to Active button is executed then nothing happens.

    The output is saved as comment in the incident. This can be changed during the creation of the task.

    Now if the incident has a status “Closed” the set to active will run.



2 Responses to Limit incident status to user groups in #servicemanager

  1. I’d like to thank you for the efforts you have put in penning this website. I’m hoping to see the same
    high-grade blog posts from you later on as well. In truth,
    your creative writing abilities has motivated me
    to get my very own blog now 😉

  2. Fernando says:

    Ich habe online mehr als drei Stunden gebrowesd ,aber selten Artikel gefunden, die so klasse wie deine sind.
    Das ist echt toll fuer mich!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s