Skip to main content
1-Visitor
November 5, 2014
Solved

[IM] query-question for multilevel relationships between items

  • November 5, 2014
  • 1 reply
  • 4995 views

Hi @all,

in the attached picture you can see a structure, how items in our changemanagement could be linked via relationship fields. All items are the same itemtype, and its also always the same relationship field. Items can have different specifications, so the item at the top is in most cases a "library" and in the middle there could be "packages" and at the bottom there are "modules".

The following relationships are possible:

library -> package

library -> module

package -> package

package -> module

So how we can build a query which returns all libraries, which have a relationship (direct or not) to modules with a certain state? All what i found is the possibilty to filter over direct relationships to the next level in this structure, but not over 3 or 4 level. And also i didnt see a way to do this with subqueries.

In a pseudo-query i would say:

Give me all libraries (which have modules in state A) or (which have packages which have modules in state A) or (which have packages which have packages (which have modules in State A))

I know that reports could give us multilevel relationship filter, but thats not what we need...

I really would appreciate any hint...

thanks, Jens

structure.png

Best answer by mrump

Hi Jens,

There is already an RFC (we got attached to it in Oct. 2010 )

Reported to R&D as enhancement RFC 145864 via CS88090

1 reply

16-Pearl
November 6, 2014

Hi Jens,

unfortunately this cannot be solved by a query.

Queries are only able to selected items that match a "filter" based on their first level of relationship (up or down)

What you describe would mean to JOIN the result of several queries. This cannot be done using sub-queries.

The only way to solve this is a report.

HTH Matthias

JensN.1-VisitorAuthor
1-Visitor
November 7, 2014

Hi Matthias,

i suspected this already

But i got help from our PTC Technical Consultant. He gave me a hint to a Qquery-function "walk". It is documented only in the ServerAdministrationGuide, not in the Workflows&Documents-Documentation and the functionality isnt available or even configurable yet in the GUI. So you have to create at least a very basic query from the cli with this command:

im createquery --queryDefinition='(walk[<relationship>] <id>)'

The <id> is holding the ID of the element where the walking-procedure should start. For later refinements you can use the GUI.

But this function has at least two limitations:

  1. This works only with one relationship field, so all items have to be related by the same relationship field
  2. You have to specify the ID of the starting element for this walk and this ID isnt changeable afterwards via GUI.

So its a first step...

kind regards, Jens

16-Pearl
November 7, 2014

Hi Jens,

I don't mean to drive you away from the walk function, but keep in mind it is documented for use within reports, at least within the 10.6 Server Administration Guide.

The official answer to this sort of functionality is still to use reports, as Matthias pointed out.

Regards,
Kael