Issues with FindPagesWithCriteria

Vote:
 

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

criterias.Add(criteria);
criterias.Add(criteriaLang);

_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?

 

 

#52073
Jul 05, 2011 11:30
Vote:
 

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.

#52074
Jul 05, 2011 12:39
Vote:
 

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: 
http://world.episerver.com/Blogs/Magnus-Paulsson/Dates/2010/12/Run-a-scheduled-job-as-a-specific-role/

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?

#52078
Jul 05, 2011 17:18
Ted
Vote:
 

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?

#52079
Jul 05, 2011 17:22
Vote:
 

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.

#52080
Jul 05, 2011 17:29
Ted
Vote:
 

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... :/

#52081
Jul 05, 2011 17:31
Vote:
 

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

#52082
Jul 05, 2011 17:35
Vote:
 

The manager class that handles the import

http://pastebin.com/FcrvsMpf

And the job itself

http://pastebin.com/SWtTxqbM

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

#52083
Jul 05, 2011 17:52
Vote:
 

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

#52084
Jul 05, 2011 18:11
Vote:
 

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;

#69984
Apr 10, 2013 14:38
Vote:
 

Goran:

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

 

Cheers

//Daniel

#73432
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.