1
Vote

Query with filter on values from Contentpicker not possible

description

I think this is a bug. It is not possible to create a query where the value of a contentpickerfield is the filter.
These are the steps to reproduce:
  1. I add a field to the type Blogpost. This field is of type
    Contentpicker. I call it Related Page.
  2. Then I create to regular pages (ContentType Page).
  3. I create 4 blogposts. Two blogposts get PageOne as selected value in the RelatedPage field. The other two posts get PageTwo as selected value in the RelatedPage.
  4. Now I create a query with filter ContentType is BlogPost. And a filter with Blog Post.Related Page equals {21} (that is the Id of PageOne).
I would expect to get results BlogPostOne and BlogPostTwo. Instead I don't get results. So is the query wrong and how should I do it then. Or is there a bug with filters for ContentPicker fields.

comments

momoski wrote Dec 3, 2012 at 9:30 PM

I have found the cause of the issue, I believe.

In the file ProjectionManager, Function GetContentQueries a call is made to the tokenizer. The values of contentitempicker are stored in the database like this {21},{22}. So if I give the value {21} as parameter for the filter the tokenizer will replace that and thus not find anything.

Making the call in that function like this:
                var filterContext = new FilterContext {
                    Query = contentQuery,
                    State = FormParametersHelper.ToDynamic(filter.State)
                    //,State = FormParametersHelper.ToDynamic(tokenizedState)
                };
makes it work. But this cannot be sustained, Because when there is a token e.g. {Content.Id} that one does not get translated.

Is there a fix which I can apply myself?

sebastienros wrote Dec 11, 2012 at 8:18 PM

Change how data is saved. + migration