cancel
Showing results for 
Search instead for 
Did you mean: 

How to access to a parent document data in a widget

Flav_BARTHE
Champ on-the-rise
Champ on-the-rise

Hello,

I currently make a table layout to display some search results.
/> But in this results, I want to display metadata which can be find in a parent document of the one which is displayed. How, in a widget, I can access to this data?
/> I saw that it is possible to use a EL expression in a widget layout editor but i didn't find the good one.
/> I managed to get the parent document Ref with this : #{document.getData().getParentRef().reference()} but I can't go further.

Somebody can help me?

thanks,

1 ACCEPTED ANSWER

Anahide_Tchertc
Elite Collaborator
Elite Collaborator

#{documentManager.getDocument(document.getData().getParentRef()).getPropertyValue("dc:title")}

Note that this won't handle the case where user does not have enough rights to access the parent. And as you're in a result layout, there's a good chance that this is bad for perfs.

An alternative (and more efficient) way of doing this would be to retrieve the property on the parent, and update it on the document, whenever it is created/moved.

View answer in original post

4 REPLIES 4

Flav_BARTHE
Champ on-the-rise
Champ on-the-rise

Ok, I find the good expression :

" #{
(document.getData().getCoreSession().getDocument(document.getData().getParentRef())).getProperty("dc:title").getValue()
} " 

But it isn't very friendly. Maybe someone knows something more easy?

How did you get it to work? On my side, It shows me a list of dc metadata (ie Nature

Use a generic widget set his type to "text", Add a custom property in the widget editor, id

Anahide_Tchertc
Elite Collaborator
Elite Collaborator

#{documentManager.getDocument(document.getData().getParentRef()).getPropertyValue("dc:title")}

Note that this won't handle the case where user does not have enough rights to access the parent. And as you're in a result layout, there's a good chance that this is bad for perfs.

An alternative (and more efficient) way of doing this would be to retrieve the property on the parent, and update it on the document, whenever it is created/moved.