Could it be that the page(s) aren't readable for anonymous users? When the scheduled job is run schedueled it will be run as an anonymous user, and the FindPagesWithCriteria function will filter based on access right.
We are aware of that the filtering may not always be appropriate, so we added a new method, FindAllPagesWithCritera, that will not filter away any pages. I think that method is included in the lates service pack for R2.
EPiServer CMS Development Team
Thanks for the answer! You are spot on. It is an Intranet, so the Everyone does not have read access to the site. But I thought FindPagesWithCriteria in R2 gave me all pages regardless of access rights. Because when I try to include access rights(AccessLevel.NoAccess), I get that the method is obsolete. "Use overload without access parameter. Access rights are ignored". Then this is not right, or what?!
I will try to upgrade to R2 SP1 or use GetChildren. Thanks for your help :)
I had the same problem running R2 with no SP
Instead of upgrading or use GetChildren you can impersonate and run the job with a specified user. Read my blog post about it: http://antecknat.se/blog/2009/03/04/scheduled-tasks-tips/
Thanks for the tip. Will definitely look into it!
I am having problems with FindPagesWithCritera in a Scheduled Job. I am importing news items from a xml feed. All news items from 2009 will be placed in an "folder page" with 2009 as the PageName.This "folder page" is created if it does not exist. The way I check this is by running FindPagesWith critera with an PropertyCriteria matching PageName against the year.
If I run the Scheduled Job with the "Start Manually" button in Admin mode, everything works fine. But when it is excecuted by the Scheduler service, the FindPagesWithCriteria always retuns 0 pages. Because of this the "folder page"is created for every imported news item.
I could of course use GetChildren or GetDescendents and there is no problem at all. But is this a bug in FindPagesWithCriteria?! I am running R2 on Vista with IIS 7.