Issues with FindPagesWithCriteria


Hi Everyone,

Seem to have an issue with FindPagesWithCriteria.

I've built an scheduled job that imports pressreleases from Cision. Also importing them into date containers.

The job imports the pressreleases without any issues, but if a new one comes in it isn't displayed in the following function i've built for a simple PageList-function on the startpage

        /// <summary>
/// Fetches a collection based on a certain page type
/// </summary>
/// <param name="pageLink">The pagelink to start from</param>
/// <param name="pageType">The page type e.g [Corporate] Press releases</param>
/// <param name="lang">The language</param>
/// <param name="count">The count to return</param>
/// <returns>A PageDataCollection</returns>
public PageDataCollection GetPages(PageReference pageLink, string pageType, string lang, int count)
PropertyCriteriaCollection criterias = new PropertyCriteriaCollection();

PropertyCriteria criteria = new PropertyCriteria();
criteria.Condition = CompareCondition.Equal;
criteria.Name = "PageTypeID";
criteria.Type = PropertyDataType.PageType;
criteria.Value = PageType.Load(pageType).ID.ToString();
criteria.Required = true;

PropertyCriteria criteriaLang = new PropertyCriteria();
criteriaLang.Condition = EPiServer.Filters.CompareCondition.Equal;
criteriaLang.Name = "PageLanguageBranch";
criteriaLang.Type = PropertyDataType.String;
criteriaLang.Value = lang; //Find swedish page versions
criteriaLang.Required = true; //Criteria must be met


_getPages = DataFactory.Instance.FindPagesWithCriteria(pageLink, criterias, lang);

return _getPages;
Even if I create a new page manually or even 5 more, only the prior pressrelease is displayed. Is it something with my criterias or?



Jul 05, 2011 11:30

The language criteria is not needed, otherwise I'm guessing the problem is in the listing control you use and/or publish status or permissions when you save pages inside the scheduled job.

Jul 05, 2011 12:39

Removed the criteria, also tried DataFactoryCache.Clear() prior to the FindPagesWithCriteria. Also tried FindAllPagesWithCriteria but that didn't work.

Also tried saving the pages with AccessLevel.NoAccess on the import job and also tried this:

Nothing seems to work. If I create a new page in EPiServer (just a test page) under the year container the page isn't displayed. Using GetChildren on the container, then it works.

A bug perhaps? Or am I doing something completely wrong?

Jul 05, 2011 17:18

FPWC isn't cached, but what happens if you insert a break point in the scheduled job code and look at the result in the getPages variable - do you see the pages you're adding?

Also, I'd remove the page language criteria from the criteria collection.

Just curious, is HTTP caching enabled?

Jul 05, 2011 17:22

If i rerun the job with an empty Pressreleases page, the pages are displayed. If a new one comes in or if I try to create a page manually under there, it's not displayed anywhere so it seems to be a bug with the import after it's initial creation.

HTTP caching is not enabled.

Jul 05, 2011 17:29

But if you inspect the 'getPages' result variable after having added a page, do you see the newly created page in the result set?

Would probably be a good idea to try and narrow it down to see if the problem is in your FPWC call, the control(s) displaying the press releases or in your scheduled job... :/

Jul 05, 2011 17:31

Can't see it at the breakpoint! Just the latest created at the initial import. Strange

Jul 05, 2011 17:35

The manager class that handles the import

And the job itself

And again, the GetChildren class on the date container, returns the created pages.

Jul 05, 2011 17:52

Had to solve it by making a sibling extension method using GetChildren, i'm going to submit a bugreport to EPiServer tho :)

Jul 05, 2011 18:11

Ran into same problem in EPiServer 7.0. Solved by impersonating an admin user (specified in web.config) before running FindPagesWithCriteria, like this:

PrincipalInfo.CurrentPrincipal = PrincipalInfo.CreatePrincipal(ConfigurationManager.AppSettings["adminUser"]);

// FindPagesWithCriteria code

// Sets impersonation back to anonymous
PrincipalInfo.CurrentPrincipal = PrincipalInfo.AnonymousPrincipal;

Apr 10, 2013 14:38


Is seems to me that you could use FindAllPagesWithCriteria equally well, and get the same result?
 Do you agree?




Jul 20, 2013 12:15
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.