Share via


$Target

Applies To: System Center Service Manager 2010

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

The $Target variable notation refers to the targeted class type of a monitoring object and allows for runtime access of the targeted class type.

$Target/[Host]/Property[Type=”Name of class”]/PropertyName$

Remarks

Within a workflow rule, the $Target variable can retrieve data from its target class type instance. For example, a rule that must groom a database nightly at midnight is targeted at the class type that hosts the databases. When you create the rule that will groom the databases, you will not know the name of the SQL Server that hosts the database or even the names of the databases that must groomed. Therefore, you can use the $Target variable to retrieve this information at run time.

The $Target variable is also used in a type projection Component element to refer to the target of a relationship type definition.

Syntax Section Description

$Target

The name of the variable you need to use.

Type=ID of ClassType

The value of ID attribute of the class type that is the target of this Management Pack element. This can be the value of the Target attribute of this Management Pack element or a class that hosts the target of this Management Pack element.

Relationship=ID of RelationshipType

The value of ID attribute of the relationship type in the type projection element.

SeedRole=ID of RelationshipType

Defines what role the seed element should play in the relationship hierarchy in a type projection. Can be one of two values: “Target” or “Source”. If “Source” is specified, the SeedRole element is the source of the relationship. If “Target is specified, the SeedRole element is the target of the relationship.

TypeConstraint=ID of RelationshipType

The value of the ID attribute of a class type instance referred to in a type projection element. Used to restrict the element to class type derivations.

PropertyName

Name of the property whose value you want to retrieve.

Host

Use if the class type in the class name section is the host of the target class.

Property

Use if you are naming a property of the class type named in the class name section.

Path

Use if you are referring to the target of a relationship type definition in a type projection definition.

The following example instructs Service Manager to find the fully qualified domain name (FQDN), which is the value of the NetworkName property, for each instance of the target class type of the containing rule definition:

<ComputerName>$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName

The following example retrieves the value of the NetworkName property for all instances of the class type that hosts the target class type. The hosting class type is the Computer class that is defined in the Microsoft Windows Library.

$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$

You can retrieve a property value from a class type instance all the way up the hosting relationship tree. You specify how high to go simply by adding another host. For example, if you wanted a value from a computer class that hosts a server class that hosts a database server class type that hosts the database, use the following syntax:

$Target/Host/Host/Host/Property

If the rule is targeted at a class type instance hosted two levels above the computer, the Host section of the syntax must be specified twice, as in $Target/Host/Host. Use the following syntax to retrieve the value of the NetworkName property from the hosting class that is two levels above the current class:

<ComputerName>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>

The value retrieved by the $Target variable can also be appended to text. The following syntax prepends SqlServer to the name of each instance of a discovered object:

 <InstanceName>SqlServer$Target/Property/SQLInstanceName$</InstanceName>

The final sample illustrates how to refer to a relationship path within a hierarchy tree for a type projection element. In this case, each target notation refers to the Target element in the specified relationship. For the Reviewer element, the relationship type is the System.ReviewActivityHasReviewer relationship type of which System.Reviewer is the target. For the User element, the relationship type is the System.ReviewerIsUser relationship type of which System.User is the target.

<TypeProjection ID="System.WorkItem.Activity.ReviewActivityViewProjection" Accessibility="Public" Type="CoreActivity!System.WorkItem.Activity.ReviewActivity">
  <Component Alias="Reviewer" Path="$Target/Path[Relationship='CoreActivity!System.ReviewActivityHasReviewer']$">
    <Component Alias="User" Path="$Target/Path[Relationship='CoreActivity!System.ReviewerIsUser']$" />
  </Component>
</TypeProjection>