Zum Hauptinhalt gehen

Get Page from its UID

Kommentare

2 Kommentare

  • Zendesk API User
    Author: mbergmann - 4/7/2017 21:31

    Hi Javier,

    first, it is recommended to use the StoreElementAgent (DEV API) to get objects - using UserService is "the old way" (but not deprecated).

    So you should get the Content2 node like this:

    StoreElementAgent storeElementAgent = context.requireSpecialist(StoreElementAgent.TYPE);

    Content2 serviceDB = (Content2) storeElementAgent.loadStoreElement("service", Content2.UID_TYPE, false);

    When working with database entries, you should always "switch up" one abstraction layer. This means using Datasets instead of Entities. Unfortunately, a query returns a List of "low level data" entities, so you have to request a corresponding Dataset. As the column "global_content" maps to a FS_REFERENCE, you can then directly access the iinput component value which is a TargetReference in this case.

    For this, you will also have to provide the name of the input component (in the TableTemplate) that maps to the column "global_content", for example "tt_globalContent" (you'll have to adjust that to your situation).

    String globalContentFieldName = "tt_globalContent";

    for (service : services){

      Dataset serviceDataset = serviceDB.getDataset(service);

      TargetReference targetReference = (TargetReference) serviceDataset.getFormData().get(null, globalContentFieldName).get();

      

      //and here is your page:

      Page page = (Page) targetReference.get();

    }

    Hope this helps.

    Michael

    0
  • Zendesk API User
    Author: brueder - 4/18/2017 13:51

    Hello Javier,

    do you need further assistance or did Michael's reply already help you? If so, it would be great if you marked his reply as "correct answer" so that other community users find the solution easily. If you already have found a solution by yourself, it would be very kind of you, if you posted it here.

    Best regards,

    Lena

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.