1

Sitecore: 9.0.2 + SXA 1.7.1

What i was trying to do: Inside a parent item 'Locations', i have multiple children items created on a common template. Each children item has a multilist field 'Location Category', as shown below.enter image description here

On the page 'Locations', i have used the rendering 'Page Content'. There I am trying to write a query to read all children under 'Locations', segregated based upon the value selected for 'Location Category'. (Idea source)

What is my problem: I tried to write the query in the powershell and was able to succesfully list the children but was not able to segregate on the basis of the selected value, as can be seen below. The first query is success while the second query is giving an error. enter image description here

What I am looking for: 1. What I am doing wrong? Is using xPath along with query a bad idea?

Edit:

How it is different: The words 'contact' or 'us' are not in the reserved keywords. And this particular combination is getting executed succesfully in the first query. Similarly 'location', 'category' and 'work' are not in the list of reserved keywords.

Please help me to find out if I missing something silly.

Thanks.

5
  • You need to escape your queries. #contact-us# instead of contact-us. – Mark Cassidy Mar 22 '19 at 16:28
  • @MarkCassidy:Sorry, possibly i couldn't put my point properly. If you see the first query in powershell, it has executed perfectly, without escaping. Then why i need to escape in the second case. – NutsAndBolts Mar 22 '19 at 17:50
  • @@ is for reserved names. Use ... locations/*[@#Location Category#='Work'] – Mark Cassidy Mar 22 '19 at 21:33
  • @MarkCassidy Sorry Mark, but it still gives the same error. Tried a lot of permuttation and combination. Will keep you posted. – NutsAndBolts Mar 25 '19 at 10:26
  • Abhishek - your problem is the same as the question referenced. You have a space in the field name, so you need to escape that field name with the # symbol, like Mark mentioned. You should not be using the @@ symbol - that is for reserved names. – Richard Seal Mar 25 '19 at 15:10

Browse other questions tagged or ask your own question.