0

I have two lists that are related. I am trying to display them with a CQWP but I never used it. How can I list the items from the parentlist with its child items?

PIR 1 My question
    SIR 1.1 My subquestin 1.1
    SIR 1.2 My subquestion 1.2
PIR 2 My second question
    SIR 2.1 My subquestion 2.1

Any ideas?

1

Querying content is based on a keyword matching defined in your CQWP's properties which is the place where you define the query. This means that the CQWP will only show the items which match to your query. Considering that your lists are probably located at the same place, you need to define 1. the location where to query and 2. the matching keyword which is constructed from the properties of the list items.

If you have your lists in e.g. the same site and there are and will not be any other lists, you may just query every list of your site. If there are or may be in the future other lists, you need to define some common property which the items of the lists share. Typically this would be a metadata (e.g. a column [PIR] with a value 1 or Yes or whichever feels natural) or a shared site content type. Other options include a shared content type group or a list type.

The below graph illustrates this:

CQWP properties explained

(Source and a related read by Microsoft: https://support.office.com/en-us/article/when-to-use-the-content-query-web-part-or-the-content-search-web-part-in-sharepoint-346a0f48-38de-409b-8a58-3bdca1768929)

  • Yes there are more lists already. I have selected the Parentlist but I can'r select multiple lists at query source. – Marco Jul 17 '18 at 10:30
  • @Marco yes, it's not possible to select multiple lists by inputting them on the "Show items from the following list". Instead, as I explained above, you need to retrieve the list contents in a query-based manner. – moe Jul 17 '18 at 10:38
  • you mean like in a sql way? SELECT * FROM.... – Marco Jul 17 '18 at 10:39
  • I use a field named PIR2SIR which is the connection between the two lists. Itś a lookup field. – Marco Jul 17 '18 at 10:41
  • No, not in SQL way, but just as the above picture indicates. In your lists you need to have some unique property either in the form of a content type or in the form of a site column. Only then you can query all of the lists and properly show the results which match to the query. If SQL is a more familiar platform for you, consider that your query would need to match the WHERE part. I suggest to familiarize yourself with SP's definition of content type and column by reading e.g. this. – moe Jul 17 '18 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.