Answered by:
Type projection seedRole problem

Question
-
I have created a typeprojection to use in a custom control on a form.
I have trouble accessing the alias PhysicalComputer. No data shows up in the form.
I use as databinding <TextBox Name="textBox2" Text="{Binding Path=PhysicalComputer.DisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="1" />
but no data shows up
Any suggestions
My typeprojection :
<TypeProjections>
<TypeProjection ID="ClientFormT1_TypeProjection" Accessibility="Public" Type="Windows!Microsoft.Windows.Client.Computer">
<Component Path="$Context/Path[Relationship='Windows!Microsoft.Windows.ComputerHostsOperatingSystem']$" Alias="OperatingSystem" />
<Component Path="$Context/Path[Relationship='Windows!Microsoft.Windows.ComputerHostsLogicalDevice' TypeConstraint='Peripherals!Microsoft.Windows.Peripheral.NetworkAdapter']$" Alias="NetworkAdapter" />
<Component Path="$Context/Path[Relationship='Windows!Microsoft.Windows.ComputerHostsLogicalDevice' TypeConstraint='Peripherals!Microsoft.Windows.Peripheral.Processor']$" Alias="Processor" />
<Component Path="$Context/Path[Relationship='Windows!Microsoft.Windows.ComputerHostsLogicalDevice' TypeConstraint='Peripherals!Microsoft.Windows.Peripheral.PhysicalDisk']$" Alias="PhysicalDisk" />
<Component Path="$Context/Path[Relationship='Windows!Microsoft.Windows.ComputerHostsLogicalDevice' TypeConstraint='Peripherals!Microsoft.Windows.Peripheral.LogicalDisk']$" Alias="LogicalDisk" />
<Component Path="$Context/Path[Relationship='Alias_a07f9867_2ae8_4e1e_9513_4c5c7eb8fef7!AMGAdministrator']$" Alias="AMGAdministrator" />
<Component Path="$Context/Path[Relationship='Alias_a07f9867_2ae8_4e1e_9513_4c5c7eb8fef7!AMGAdministratorBackUp']$" Alias="AMGAdministratorBackUp" />
<Component Path="$Context/Path[Relationship='ConfigMgr!Microsoft.SystemCenter.ConfigurationManager.DeployedComputerRunsWindowsComputer' SeedRole='Target']$" Alias="PhysicalComputer" />
</TypeProjection>
</TypeProjections>Wednesday, February 25, 2015 1:28 PM
Answers
-
Are you sure on this? We can control type of relationship (1-1, 1-many, many-many) using MaxCardinality, if it set to 1 for both, source and target, then this will be 1-1.
Yep I'm sure. I just double-checked in case they've fixed it since 2012. The SDK does not enforce MaxCardinality values of 1 on relationship sources.
Let's say you have objects 'A', 'B', and 'C'. Create a many-to-1 relationship type. 'A' will be your source object, 'B' and 'C' will be your target objects. Create relationships between (A and B) and (A and C). You'll find that as soon as you create the relationship between A and C, the relationship between A and B is set to "IsDeleted" in the database.
Now create a 1-to-many relationship type. B and C will be your source objects and A will be your target object. Create relationships between (B and A) and (C and A). You'll find that both relationships are maintained in the database even though the MaxCardinality of the source is set to 1. The SDK has not enforced the source MaxCardinality.
- Edited by Aaron Croasmun Sunday, March 1, 2015 4:26 AM clarity
- Marked as answer by Yan Li_ Thursday, March 5, 2015 1:43 AM
Sunday, March 1, 2015 4:25 AM
All replies
-
The DeployedComputerRunsWindowsComputer relationship is many-to-1. This means that a single Windows Computer record can be related to many Deployed Computer records, but a Deployed Computer record can be related to only zero or one Windows Computer record.
According to your type projection, you're correctly setting the SeedRole='Target'. However, this means that particular component is a collection (because a single windows computer..the target..can be related to MANY deployed computer records).
You can not bind a collection of objects to a single control like a textbox or checkbox. You should bind that collection to a listbox.
However, the "trick" to doing it is to set your textbox's binding path to PhysicalComputer[0].DisplayName. That tells the binding path to bind to the first PhysicalComputer in the collection (which is generally bad practice)
Generally a windows computer will only ever have one deployed computer record (technically, the relationship should be 1-to-1). However, the SCSM framework does not support a source cardinality of 1 for relationship types. All source max cardinalities are treated as 2147483647.
- Edited by Aaron Croasmun Wednesday, February 25, 2015 2:44 PM
Wednesday, February 25, 2015 2:41 PM -
Thank you for you help.
It did the trick.
I can't get the 'Serviced By user' to work.
<Component Path="$Context/Path[Relationship='System!System.ConfigItemServicedByUser']$" Alias="ServicedBy" />
I tried <smcontrols:UserPicker Name="userPicker1" User="{Binding Path=ServicedBy[0], Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="5" />
But that didn't work.
What I am doing wrong with this relation. It's not 1-1 relation. I think 1 to many
Wednesday, February 25, 2015 8:28 PM -
That relationship is many-to-many, not 1-to-many. (Technically, in SCSM's framework, there's no such thing as 1-to-many or 1-to-1). The UserPicker control might not be smart enough to recognize the difference between a single object and a single object from a collection. You might need to use a ListView with that one.
However, have you verified that a user is actually related to your windows computer record? That's always the first step. If you have verified that the relationship exists, then you can start debugging your binding/type projection/etc. I've seen many folks (myself included) waste hours trying to debug a binding only to find out that there was never a related object in the first place.
Wednesday, February 25, 2015 8:35 PM -
Technically, in SCSM's framework, there's no such thing as 1-to-many or 1-to-1
SCSMSolutions
email: freemanru (at) gmail (dot) comSaturday, February 28, 2015 7:06 PM -
Are you sure on this? We can control type of relationship (1-1, 1-many, many-many) using MaxCardinality, if it set to 1 for both, source and target, then this will be 1-1.
Yep I'm sure. I just double-checked in case they've fixed it since 2012. The SDK does not enforce MaxCardinality values of 1 on relationship sources.
Let's say you have objects 'A', 'B', and 'C'. Create a many-to-1 relationship type. 'A' will be your source object, 'B' and 'C' will be your target objects. Create relationships between (A and B) and (A and C). You'll find that as soon as you create the relationship between A and C, the relationship between A and B is set to "IsDeleted" in the database.
Now create a 1-to-many relationship type. B and C will be your source objects and A will be your target object. Create relationships between (B and A) and (C and A). You'll find that both relationships are maintained in the database even though the MaxCardinality of the source is set to 1. The SDK has not enforced the source MaxCardinality.
- Edited by Aaron Croasmun Sunday, March 1, 2015 4:26 AM clarity
- Marked as answer by Yan Li_ Thursday, March 5, 2015 1:43 AM
Sunday, March 1, 2015 4:25 AM