The existing project is upgraded from Sitecore 8.0 to Sitecore 9.0u1. After that, I've observed that few renderings are not working. The root cause is, controller rendering datasource query.

If controller rendering datasource has query like "query:./ancestor-or-self::[@@templatename='AgentWebsite']//[@@templatename='Site Root']", then it is not hitting the controller action. If I remove the datasource query, it is hitting properly.

I observed below warning in log file.

2708 00:09:21 WARN 'query:./ancestor-or-self::[@@templatename='AgentWebsite']//[@@templatename='Site Root']' is not valid datasource for web or user does not have permissions to access.

Can we convert the above query to make it work on Sitecore 9?

  • Can you try it like this query:./ancestor-or-self::*[@@templatename='AgentWebsite']//[@@templatename='Site Root'] or query:./ancestor-or-self::*[@@templatename='AgentWebsite']/*[@@templatename='Site Root'] or query:./ancestor-or-self::*[@@templatename='AgentWebsite']/*/[@@templatename='Site Root'] . I think that you are missing * after "ancestor-or-self::" and also "//" seems weird. Maybe this is causing Sitecore 9 not to work as expected. Maybe they have fixed something in that version which was not working as expecting in Sitecore 8 but of course working for you ;) Commented Jun 20, 2018 at 6:40
  • Hi Peter, I tried all options you suggested, but no luck. In the sitecore post ( community.sitecore.net/developers/f/8/t/8683) mentioned that 'query:self::*/' Or "query:/" are invalid formats from Sitecore 8.2 on wards.
    – venkat
    Commented Jun 21, 2018 at 0:16

1 Answer 1


Your query isn't wrong. And you don't need to change it for 9.0.

You've not shared your configuration nor your stack traces or anything else that might help, but my best guess is this:

In your 8.0 solution, you had implemented Queryable Datasources. Out of the box, your query is not supported on either Sitecore 8 or Sitecore 9.

And then I assume, this has not been noticed in the upgrade process and has therefore not been moved across to your Sitecore 9 installation. Move it, and your query should work as before.

on a side note: It looks like your query is designed to get the Site Root item of the current site you are on. There are far better ways of doing that, than via Sitecore Query. Just saying :-)

  • Mark, thanks for your analysis. Correct, we had implemented Queryable Datasources. We resolved by altering RenderingContext in a pipeline. I observed that before hitting the Queryable Datasources, the query validation is failing.
    – venkat
    Commented Jun 23, 2018 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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