Bidirectional Navigation

Apr 27, 2009 at 8:03 PM
I am trying to manage an association from either side but that does not seem to be possible. Initially I setup one end of the association to make sure that it was working and then tried to setup the other end of the association. I think it would work if the field order in the config file was honored rather than assuming the list item ID for the current item is always the first value in the join table and if a duplication check was made before the insert.

Perhaps I am missing something. Is it possible? The following is my map:

  <DataMapping DataSchema="SLAM" SiteCollection="sites/pica">
    <List Site="samer" Name="pica.Applications" ActivationOrder="1">
      <Fields>
        <Field Name="Title" SqlType="varchar(255)" SPType="Text" Required="true"></Field>
        <Field Name="System" SqlType="Lookup" AssociatedList="pica.Systems" AssociationName="SystemsToApplications"></Field>
      </Fields>
    </List>
    <List Site="samer" Name="pica.Systems" ActivationOrder="2">
      <Fields>
        <Field Name="Title" SqlType="varchar(255)" SPType="Text" Required="true"></Field>
        <Field Name="Applications" SqlType="Lookup" AssociatedList="pica.Applications" AssociationName="SystemsToApplications"></Field>
      </Fields>
    </List>
  </DataMapping>



Developer
Apr 28, 2009 at 12:18 AM
As you can tell SLAM treats associations unidirectionally, but it does of course because SharePoint treats lookups in this manner.  The association is a manifestation of that lookup relationship.  If you have a requirement for a bidirecitonal relationship it seems probable you have more to worry about than what SLAM is doing when it comes to data integrity in SharePoint.  I am assuming in this case that when you set a lookup value in an Application to a System that also sets the reciprocal relationship in that System item.  I would also assume you would use an event receiver to do this and you want it to coordinate with SLAM.  If this is the requirement then it's a perfect example of where you would use a custom Type Profile.  In fact when we have had such a bidirectional requriement we have created such a custom project-specific Profile to do ensure the data integriry in SharePoint AND in SLAM.  Storing the relationship in SLAM but not in SharePoint seems less than ideal to say the least.  It may be a bit more complex of an example but I highly suggest you check out of the Hierarchy extension source code to see how a custom profile works.  If you have more questions related to that, if that is indeed what you need to do (to handle the reciprocal relationship in SharePoint and SLAM) feel free.
Thanks,
-Brian