Many to Many Relationships

Anyone have any experience creating many-to-many relationships in Service Manager?  For example, I am looking to extend the "Business Service" class with an additional list of IT contacts.  If anyone has any references on how to go about something like this, it would be much appreciated!

September 1st, 2015 3:49pm

Here is the XML for a one-to-many

<RelationshipType ID="HasRelatedWorkItem" Accessibility="Public" Abstract="false" Base="System!System.Reference">
      <Source ID="Source.CustomClass.HasRelatedWorkItem" MinCardinality="0" MaxCardinality="2147483647" Type="Client" />
      <Target ID="Target.WorkItem" MinCardinality="0" MaxCardinality="1" Type="WorkItemLibrary!System.WorkItem" />
</RelationshipType>

In this instance, to make it many-to-many, you would need to change the MaxCardinality for the Target to 2147483647.

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 5:46pm

What about the form?  The authoring tool does not seem to have the list box control to support this.  Is this where you have to build something custom in Visual Studio?

Thanks!

September 1st, 2015 6:55pm

You can use your favorite XML editor to create a management pack and extend the class.  If you are going to use this in a form, than I suggest you read up on Type Projections.
Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 7:40pm

Is this where you have to build something custom in Visual Studio?


Yes. 1-to-many and many-to-many relationships require a listbox control which the authoring tool doesn't have. Once you've created the relationship and added it to your form's type projection, you need to extend the business service form with a custom control. The custom control, in this case, would be a WPF UserControl that merely contains a listbox configured however you wish. The ItemsSource binding must then match the alias of your relationship's component in the type projection.

Anton's post will get you started building a custom control and extending an existing form with it. http://blog.scsmsolutions.com/2011/08/create-custom-user-control-for-scsm-2010/ The important part is to replace the XAML with your own xaml (in your case a listbox).

Incidentally, Foothill, the relationship you posted is many-to-1. The distinction is important :)

September 1st, 2015 7:56pm

Here is the XML for a one-to-many

<RelationshipType ID="HasRelatedWorkItem" Accessibility="Public" Abstract="false" Base="System!System.Reference">
      <Source ID="Source.CustomClass.HasRelatedWorkItem" MinCardinality="0" MaxCardinality="2147483647" Type="Client" />
      <Target ID="Target.WorkItem" MinCardinality="0" MaxCardinality="1" Type="WorkItemLibrary!System.WorkItem" />
</RelationshipType>

In this instance, to make it many-to-many, you would need to change the MaxCardinality for the Target to 2147483647.

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 9:43pm

Here is the XML for a one-to-many

<RelationshipType ID="HasRelatedWorkItem" Accessibility="Public" Abstract="false" Base="System!System.Reference">
      <Source ID="Source.CustomClass.HasRelatedWorkItem" MinCardinality="0" MaxCardinality="2147483647" Type="Client" />
      <Target ID="Target.WorkItem" MinCardinality="0" MaxCardinality="1" Type="WorkItemLibrary!System.WorkItem" />
</RelationshipType>

In this instance, to make it many-to-many, you would need to change the MaxCardinality for the Target to 2147483647.

September 1st, 2015 9:43pm

Here is the XML for a one-to-many

<RelationshipType ID="HasRelatedWorkItem" Accessibility="Public" Abstract="false" Base="System!System.Reference">
      <Source ID="Source.CustomClass.HasRelatedWorkItem" MinCardinality="0" MaxCardinality="2147483647" Type="Client" />
      <Target ID="Target.WorkItem" MinCardinality="0" MaxCardinality="1" Type="WorkItemLibrary!System.WorkItem" />
</RelationshipType>

In this instance, to make it many-to-many, you would need to change the MaxCardinality for the Target to 2147483647.

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 9:43pm

Here is the XML for a one-to-many

<RelationshipType ID="HasRelatedWorkItem" Accessibility="Public" Abstract="false" Base="System!System.Reference">
      <Source ID="Source.CustomClass.HasRelatedWorkItem" MinCardinality="0" MaxCardinality="2147483647" Type="Client" />
      <Target ID="Target.WorkItem" MinCardinality="0" MaxCardinality="1" Type="WorkItemLibrary!System.WorkItem" />
</RelationshipType>

In this instance, to make it many-to-many, you would need to change the MaxCardinality for the Target to 2147483647.

September 1st, 2015 9:43pm

Is this where you have to build something custom in Visual Studio?


Yes. 1-to-many and many-to-many relationships require a listbox control which the authoring tool doesn't have. Once you've created the relationship and added it to your form's type projection, you need to extend the business service form with a custom control. The custom control, in this case, would be a WPF UserControl that merely contains a listbox configured however you wish. The ItemsSource binding must then match the alias of your relationship's component in the type projection.

Anton's post will get you started building a custom control and extending an existing form with it. http://blog.scsmsolutions.com/2011/08/create-custom-user-control-for-scsm-2010/ The important part is to replace the XAML with your own xaml (in your case a listbox).

Incidentally, Foothill, the relationship you posted is many-to-1. The distinction is important :)

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 11:53pm

Is this where you have to build something custom in Visual Studio?


Yes. 1-to-many and many-to-many relationships require a listbox control which the authoring tool doesn't have. Once you've created the relationship and added it to your form's type projection, you need to extend the business service form with a custom control. The custom control, in this case, would be a WPF UserControl that merely contains a listbox configured however you wish. The ItemsSource binding must then match the alias of your relationship's component in the type projection.

Anton's post will get you started building a custom control and extending an existing form with it. http://blog.scsmsolutions.com/2011/08/create-custom-user-control-for-scsm-2010/ The important part is to replace the XAML with your own xaml (in your case a listbox).

Incidentally, Foothill, the relationship you posted is many-to-1. The distinction is important :)

September 1st, 2015 11:53pm

Is this where you have to build something custom in Visual Studio?


Yes. 1-to-many and many-to-many relationships require a listbox control which the authoring tool doesn't have. Once you've created the relationship and added it to your form's type projection, you need to extend the business service form with a custom control. The custom control, in this case, would be a WPF UserControl that merely contains a listbox configured however you wish. The ItemsSource binding must then match the alias of your relationship's component in the type projection.

Anton's post will get you started building a custom control and extending an existing form with it. http://blog.scsmsolutions.com/2011/08/create-custom-user-control-for-scsm-2010/ The important part is to replace the XAML with your own xaml (in your case a listbox).

Incidentally, Foothill, the relationship you posted is many-to-1. The distinction is important :)

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 11:53pm

Is this where you have to build something custom in Visual Studio?


Yes. 1-to-many and many-to-many relationships require a listbox control which the authoring tool doesn't have. Once you've created the relationship and added it to your form's type projection, you need to extend the business service form with a custom control. The custom control, in this case, would be a WPF UserControl that merely contains a listbox configured however you wish. The ItemsSource binding must then match the alias of your relationship's component in the type projection.

Anton's post will get you started building a custom control and extending an existing form with it. http://blog.scsmsolutions.com/2011/08/create-custom-user-control-for-scsm-2010/ The important part is to replace the XAML with your own xaml (in your case a listbox).

Incidentally, Foothill, the relationship you posted is many-to-1. The distinction is important :)

September 1st, 2015 11:53pm

Great, thanks much for the feedback!
Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 6:38pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics