Fetching a page / page field-data

So basically I’m trying to fetch some field-data from the brandpage that is related to a product.
In the accelerator, there is already a method for just this ( Litium.Accelerator.Builders.Product.ProductPageViewModelBuilder.GetBrandPage() ). The problem is that no field-data seems to be fetched, but the id is correct.

So is there way to either fetch the pagemodel with it’s fields from the id, or to the get the pagemodel to fetch its fields?

Litium version: 7

First of all, make sure your page is published in order to get its field data. If the page is never published, the default page data contains nothing, maybe only the page name.

To get page’s fields, use PageService.Get(Guid systemId) to get the page object, then you can access its fields via page.Fields.

In case you want to get the field data of the Draft, use DraftPageService instead.

The page is published. And when using PageService, the only fields that I can get is seems to be SystemFields for the BrandPage.

In the GetBrandPage method, I have added this for when I find the correct page:
result = _pageService.Get(page.SystemId).MapTo().MapTo();
But all the properties in BrandViewModel that I have auto-mapped are null.

Is there any other fields on the page that you have added field to?
Are that fields culture dependent or culture independent?

If you check the result for _pageService.Get(page.SystemId), will that contains the field you expect?
In case they are there, do the first .MapTo<PageModel>() include the fields that you expect?

Yes I have added new Fields, but they work just fine when I access the actual brand page.
The new fields are not culture dependent.

If you check the result for _pageService.Get(page.SystemId) , will that contains the field you expect?

No they are not there unfortunately.

If you try to fetch the draft instead of the page, will you have the field values there?

_draftPageService.Get(page.SystemId)

Sorry, I’m really embarrassed to say. That page had not been published. I had tried to publish the page in a different tab, and had gotten an error message that I missed.
It’s working now, and I’m really sorry for wasting your time. But thank you all anyways!!

No problem, and glad that you get it to work :slight_smile:

2 Likes