Hi Dynamicweb,
We've got an IndexBuilder where we want to get the Page by the PageID.
However the method 'GetPageById' returns a null object reference when we pass an existing pageID in the method.
Here's our error:
Object reference not set to an instance of an object. at Dynamicweb.Frontend.ApplicationLoad.get_PageCache() at Dynamicweb.Content.Page.GetPageById(Int32 id, Boolean force) at Dynamicweb.Content.Page.GetPageById(Int32 id) at Bluedesk.FullTextIndex.FullTextIndexBuilder.Build(IIndexWriter writer, Tracker tracker) in C:\vso\Alkmaar Marketing\Tools\Bluedesk.FullTextIndex\FullTextIndexBuilder.cs:line 177 at Dynamicweb.Indexing.Index.Build(String instance, String name, Tracker tracker) at Dynamicweb.Indexing.IndexService.<>c__DisplayClass1.b__0(Tracker tracker)
And here's the code:
var thispage = Dynamicweb.Content.Page.GetPageById(pageID); if (thispage != null && thispage.Parent != null) { var parentpage = thispage.Parent; var categoryName = parentpage.ItemType.Equals("EventCategory") ? parentpage.MenuText : parentpage.Parent.ItemType.Equals("EventCategory") ? parentpage.Parent.MenuText : ""; doc.Add("CategoryName", categoryName); }
Best regards,
Justin.