top of page
  • Glen (Xapity)

PowerShell for SCSM: Push Data via Relationship to Work Item

PowerShell for SCSM: Push Data via Relationship to Work Item

Why do you want to do this? Quite often you will need to get data from the another work item and a Service Manager relationship will

provide the connection between the objects. Relationships have a source and target object and we can start from either side and still use the relationship to connect to the other object.

When starting from the source object you can use the Get-SCSMRelatedObject to connect to the target. This would be an example of a "push" of data from the source to the target. But this does not work in reverse, when starting from the target.

When starting from the target object, you can use the Get-SCSMObject and Get-SCSMRelationshipObject to get to the source object as shown in the script below. This is an example of a "pull" of data from the source to the target.

The example below can be used by a Xapity PowerShell Activity placed on the Parent work item that is uses the Xapity Create Activity to create a work item (in which case do not use the "wait for completion" option). This would be appropriate to copy data from the Parent to any Problem or Incidents created by the Created Activity.

What does it do? In this example we have a Service Request that contains a Xapity Create Activity that will create an Incident.

The Relationship that connects the Create Activity to the Incident is Xapity.CreateActivity.DependsOnWorkItem. This is a custom one to one relationship that comes with the Xapity Create Activity.

We are starting from the Parent Service Request, so the first thing is to find the Create Activity (there may be more than one). Then we can find the Incident object from the Create Activity and then copy data between the Parent Service Request and new Incident.

High Level Explanation of the Script (download below) First as always define the variables, classes and relationships to be used in the script. By using the higher level class of "System.WorkItem" we can avoid having to define all the individual work item classes - IR, PR, SR, CR, RR and in this case the custom Create Activity as well.

Then we need to get all the activities on the Service Request. In this case we can narrow it down tot eh Create Activities using the type name of Xapity.WorkItem.Activity.CreateActivity. This can potentially give us multiple Create Activities. Use a 'For loop' to process through the activities using a keyword in the title to target the one(s) that you want to use to find the target object.

As we are starting from the source of the relationship, we can use the command Get-SCSMRelatedObject and the relationship DependsOnWorkItem to find the target created object.

Once we have the CreatedObject we can then update the Title in this example. But you could push down any data you need from the Parent Service Request to the new Incident (in this example).

Full Script

Download the script:

Read more PowerShell for SCSM blogs


Xapity PowerShell Activity for SCSM

Xapity PowerShell Activity

The Xapity PowerShell Activity is a new Activity for SCSM that enables PowerShell scripts to be run in SCSM. Automate more of your processes directly in SCSM. Scripts are stored and updated from a central script repository. The scripts execution output can be viewed and if a failure occurs, an email notification can be sent.

Xapity Create Activity for SCSM

Xapity Create Activity

Xapity Create Activity allows major Work Item types to be created from SCSM Change Requests, Release Records and Service Requests. For example, you can create a Change Request from a Service Request activity workflow and wait for it to be completed before progressing.

Xapity - Innovative Software for SCSM - Discover our Products

#CreateActivity #PowerShell #SelfServicePortal #PowerShellActivity #Tips #SCSM

134 views0 comments

Recent Posts

See All
bottom of page