May
08

Customizing the Query Result Prompt

By

When defining a request offering you have the option to add different prompts used to collect information from an end user. One of the prompts available is the Query Result prompt type. A query result prompt is a control that can list the result of a query executed against the Service Manager CMDB so that a user can select resources from that list as input when making a request or when reporting an incident.

If you choose to add a query result prompt you’ll need to configure it as well. In the configuration you’ll describe which kind of objects you want to query for, which criterias they should fulfill and which data to show in the table that lists the result. One of the final options you’ll have is to choose if you want to add the selected items as either “A related item” or “An affected configuration item” (as seen in the picture below.

Now let’s say you want to add the selected objects as something else, maybe even using one of your custom relationship types?!

As it turns out, this can easily be achieved by editing the MP where you stored your request offering and doing a small modification to the XML. If open the MP you’ll find a section called “RequestOfferings”. In your request offering (use the Title attribute to make the identification of a specific request offering easier), you’ll find a section called “Targets”. Depending on which checkboxes you selected in the UI, the content of the Targets section will differ. If you’ve checked both options, as in the picture, it contains the following two targets:

<Targets>
 <Target Path="" OutputName="$InstanceValue$" RelationshipId="D96C8B59-8554-6E77-0AA7-F51448868B43" />
 <Target Path="" OutputName="$InstanceValue$" RelationshipId="B73A6094-C64C-B0FF-9706-1822DF5C2E82" />
</Targets>

If you want to add custom relationship types as targets, it’s just a matter of copying one of the existing ones and changing the relationship id to match the relationship you want to use.

Tip: To add another target you’ll need to find get the relationship id of the relationship you want to use. This can easily be done using smlets (http://smlets.codeplex.com). Using smlets, just run the following command:

PS> Get-SCSMRelationshipClass|ft Name,DisplayName,Id

Below is an example where I’ve added two custom relationships as targets.

<Targets>
 <Target Path="" OutputName="$InstanceValue$" RelationshipId="D96C8B59-8554-6E77-0AA7-F51448868B43" />
 <Target Path="" OutputName="$InstanceValue$" RelationshipId="B73A6094-C64C-B0FF-9706-1822DF5C2E82" />
 <!--Custom Target Max Cardinality 2147483647-->
 <Target Path="" OutputName="$InstanceValue$" RelationshipId="53287fcd-8797-3cb5-2014-7deb12a2ed8d" />
 <!--Custom Target Max Cardinality 1-->
 <Target Path="" OutputName="$InstanceValue$" RelationshipId="5d3e92c4-ded5-013f-e6b5-ca6f8967e672" />
</Targets>

In my request offering i list users from the CMDB. When the request is submitted a new Service Request is created and the selected user (in this case Patrik Sundqvist) is related to the request through both of the standard relationships as well as two custom ones. In the picture below you can see that four of the relationships added during the creation of the request comes from the query result prompt, these are underlined. The two that has a solid line is the standard ones (added when you check the checkboxes in the UI), the dotted lines shows the two custom relationships that I added as targets in the MP directly.

Note that the Path attribute of the Target defines which component in the type projection that should act as Source the relationship that is going to be established. If Path is empty the seed class e.g. the service request will be the source of the relationship.

You can download an example mp here which contains a couple of custom relationships and a request offering with customized query result prompt targets.

Categories : Uncategorized

Comments

  1. Jay says:

    HI Patrik,

    I’m trying to use your example as a way of adding an additional affected CI to the Service Request so that I have a total of two. I need to be able to extract those two affected CIs from the SR into an Orchestrator runbook. By default, as far as I can tell, it’s only possible to add one query result as an affected CI because there is no way of distinguishing between more than one in Orchestrator.

    So I’ve been referred your post here as a way to accomplish what I’m trying to do by building a custom relationship for the second affected CI. What I’m confused about is where you get the GUID for your custom relationship ID. You mention using the Get-SCSMRelationshipClass smlet but the custom ID doesn’t exist. So where does it come from?

    You can see my post about this here: http://social.technet.microsoft.com/Forums/en-US/connectors/thread/5701e4b4-0565-4c83-a06c-41dbabfab13f

    Thanks

  2. Guido Ploum says:

    Dear SCSM people,

    How to add a company dimension/view in the standard reports?

    I would like to use the SCSM standard incident management reports by company.

    Unfortanetly the standard reports does not contain the possibility to create a view per company. The company field is part of the affected user table.

    I’m wondering if there is an example how to customize the reports to include the company field? Any suggestions?

    In my opinion a solution can be setting up a master data table with company information and connect this table to the user table.

    At the end this must be integrated and customized in the datawarehouse too.

    Looking forward to discuss this further!

    Thanks in advance.

Leave a Reply