Get Related Pages on the right side where relationship name is Adhoc

Shweta S asked on May 17, 2017 20:07

I have a form with a field to add Pages of a page type [CMS.Schedule] (creates adhoc relationship). For the page type [CMS.Event] which contains this field, I am able to get related pages using below repeater settings

<cms:CMSRepeater ID="RelatedPages" runat="server" ClassNames="CMS.Schedule" Path="/%" TransformationName="CMS.Schedule.List" RelationshipName="CMS.Event_{guidid}" RelationshipWithNodeGUID='<%# Eval<Guid>("NodeGUID") %>' RelatedNodeIsOnTheLeftSide="true" />

But to get the related events for a schedule, I am not able to make this work

<cms:CMSRepeater ID="RelatedPages2" runat="server" ClassNames="CMS.Event" Path="/%" TransformationName="CMS.Event.List" RelationshipName="CMS.Event_{guidid}" RelationshipWithNodeGUID='<%# Eval<Guid>("NodeGUID") %>' RelatedNodeIsOnTheLeftSide="false" />

If my field type is related pages, then it works both ways by using relationship name as 'isrelatedto' but for an Adhoc relationship it does not work when related node is on the right side.

Any idea?

Correct Answer

Trevor Fayas answered on May 18, 2017 15:27

I would check the database to see how your adhoc relationship is being represented. It's the CMS_Relationship table.

In the table itself, there is a "RelationshipIsAdHoc" so it could be that by default this is filtered to where only Null or 0 (false) are selected, and if it's (1) it's filtered out. I don't see a property on the repeater to specify this so not sure if it can be tested.

Another option is to use a normal repeater, not use the related fields, and simply use the WHERE condition to formulate your query like the below:

Where: NodeID in (Select LeftNodeID from CMS_Relationship where RightNodeID = {% Convert.ToInt(CurrentDocument.NodeID, -1) |(identity)GlobalAdministrator%})

1 votesVote for this answer Unmark Correct answer

Recent Answers

Shweta S answered on May 19, 2017 01:51 (last edited on May 19, 2017 02:01)

Thank you Trevor. I tried using the where condition and it works.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.