Skip to main content
Inspiring
March 27, 2014
Answered

How to get UIDs of pages containing a given PageItem

  • March 27, 2014
  • 1 reply
  • 972 views

Hi,

I have the UID for a PageItem and I'm trying to get a list of the UIDs of the pages which the item is on.

I'm using GetPageUIDs:

IDocument* doc = Utils<ILayoutUIUtils>()->GetFrontDocument();

if (doc != nil) {

    IDataBase* db = ::GetDataBase(doc);

    UIDRef itemUidRef = UIDRef(db, itemUid);

    InterfacePtr<IHierarchy> itemHierarchy(itemUidRef, UseDefaultIID());

    if ((itemHierarchy != nil) && (itemHierarchy->GetChildCount() > 0)) {

        UIDList onPageUIDs;

        Utils<IFormFieldUtils>()->GetPageUIDs(itemHierarchy, &onPageUIDs);

        ...

    }

}

For every item, I get an empty list in onPageUIDs.

I can't find any examples for the correct way to use this function - am I using it wrong?

Thanks

Liz

This topic has been closed for replies.
Correct answer Bartek_Kropaczewski

Hi

I think FormField is some special form of page item.

Try GetItemsOnPage from ISpread interface.

Regards

Bartek

1 reply

Bartek_Kropaczewski
Bartek_KropaczewskiCorrect answer
Inspiring
March 27, 2014

Hi

I think FormField is some special form of page item.

Try GetItemsOnPage from ISpread interface.

Regards

Bartek

LizWAuthor
Inspiring
March 27, 2014

Ahhh I see - so there's no way of navigating back up from a standard page item to it's page(s)? i.e. you have to check every page to see if the item is on there...

I guess I'll write myself a helper function to do it if that's the case.

Thanks

Bartek_Kropaczewski
Inspiring
March 27, 2014

Maybe there is an easier way to get that but iterating through list of spreads and master spreads should be fast enough.