How to access to a parent document data in a widget
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,
#{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.
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?
Sujets
Droits
Source …)
Maybe the first parenthesis is useless, i think you can delete it (with a parenthesis after getParentRef()of course)