Groovy


Retrieve the first object (index [0]) among all objects attached to this page and class XWikiComments

obj = doc.getObject('XWiki.XWikiComments')

com.xpn.xwiki.api.Object@bcb1961

Retrieve all objects attached to this page and of class XWikiComments

objs = doc.getObjects('XWiki.XWikiComments')

[com.xpn.xwiki.api.Object@5d358548, com.xpn.xwiki.api.Object@64c169c6, com.xpn.xwiki.api.Object@560779d7, com.xpn.xwiki.api.Object@4d03e61, com.xpn.xwiki.api.Object@3af54bf, com.xpn.xwiki.api.Object@6be4c97c, com.xpn.xwiki.api.Object@7968233a, com.xpn.xwiki.api.Object@23e0f31b, com.xpn.xwiki.api.Object@5788404, com.xpn.xwiki.api.Object@2b23256a]

Retrieve the author property of all objects attached to this page and of class XWikiComments

objsAuthors = doc.getObjects('XWiki.XWikiComments').author
println objsAuthors

[26/02/2017 08:50:18, 26/02/2017 08:50:26, 26/02/2017 08:50:33, 26/02/2017 08:50:43, 27/02/2017 08:19:40, 27/02/2017 08:20:00, 27/02/2017 08:20:54, 27/02/2017 10:22:23, 27/02/2017 10:23:01, 27/02/2017 10:58:47]

Retrieve the author property of the fifth object attached to this page and of class XWikiComments by index

objsAuthor = doc.getObjects('XWiki.XWikiComments')[4].author
println objsAuthor

XWiki.IsabelListaGarcia

Retrieve the author property of the first object attached to this page and of class XWikiComments by index; objs was assigned above!

println objs[0].author

XWiki.RicardoRodriguezFernandez

Tags:
Created by Ricardo Rodríguez Fernández on 2017/02/15 23:05
    
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 7.3 - Documentation