Try our conversational search powered by Generative AI!

Dynamically created pages - help please

Vote:
 

Hi all,

I am trying to dynamically create pages. No exceptions are raised but the pages aren't being created.

I have checked the page type and parent page id are correct. I have checked the tblPage table in the database and no records are being added.

I am currently using the process below and need to find out how i can get an exception raised to give me more information or find out how i can debug the code.

EpiServer log is set to value 'All' but no exceptions are written to the log.

PageType pageType = PageType.Load(PageTypeNames.NUSExtra2010DiscountDetailImported);

PageData pageData = DataFactory.Instance.GetDefaultPageData(new PageReference(_graduateExtraDiscountsPageId), pageType.ID, AccessLevel.NoAccess);

pageData.PageName = graduateDiscount.CompanyName;

pageData.Property[GraduateDiscountPagePropertyNames.IsGraduateDiscount].Value = true;

//etc

pageData.VisibleInMenu = true;

pageData.StartPublish = DateTime.Now;

DataFactory.Instance.Save(pageData, EPiServer.DataAccess.SaveAction.Publish, AccessLevel.NoAccess);

Any help would be much appreciated. :)

Thanks. 

#43634
Sep 20, 2010 21:49
Vote:
 

Hi David,

DataFactory.Instance.Save method returns a new PageReference to the saved page.

Have you check what it returns to you? Is it null (empty) or set to some proper value?

#43637
Sep 20, 2010 23:35
Vote:
 

This might be a silly question, but where are you creating the page?  I mean, where is its parent page?  I use much the same process to add comments to pages, and the only thing that's substantially different between my code and yours is that you seem to be creating a new parent page (of type _graduateExtraDiscountsPageId) on the fly; but then, maybe I'm confused by what your code is actually doing.

Just in case it's helpful, my equivalent line of code is: pdNewComment As PageData = DataFactory.Instance.GetDefaultPageData(CurrentPage.PageLink, "Comment")

Um, so as you might notice, I'm creating the new comment page as a child of the current page.

#43642
Sep 21, 2010 5:07
Vote:
 

Adding to what's already been suggested, here are some more things to check:

It could be that the parent page ID is invalid. The PageReference won't protest if you create a new instance of it with an Id that doesn't correspond to a page. I also looked in GetDefaultPageData and there is a check that the PageReference has an Id set, but not that it's an existing one. At least not right away. One would think that this would result in an exception at one point or another though.

An other thing - the overloads with Accesslevel are obsolete but I don't think that's the cause either. How about language branches? You don't pass a specific language branch so it's autoselected. Is it perhaps crated in the wrong language? Then you should of course still see it in the page tree.

#43650
Sep 21, 2010 7:46
Vote:
 

Thanks for the suggestions so far. I have created other pages dynamically in the same way but am unable to see what is wrong in this case.

I don't think it is a problem with the parent page as i tried creating a new page type with no properties and adding it in the same way which worked ok.

That suggests there is a problem with one of the many properties on the page but i really wanted to find out how to see an exception.

Are there any other ways of debugging what happens within the save? As no exceptions are logged or raised i can only test by removing all properties and adding one back at a time.

Thanks.

#43663
Sep 21, 2010 10:49
Vote:
 

Any chance the page type has some mandatory properties? One thinks that would either be ignored or raise an exception in DataFactory, but maybe it's the problem?

Please post your findings if you add the properties one by one!

#43679
Sep 21, 2010 15:50
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.