Velocity script access page-object data

Hi,

In the process of creating a help system for a software I’m trying to give xwiki pages unique numeric identifiers by which they can be referred to using an URL parameter (like https://…/?helpId=42). I have managed to create velocity code that assigns each help page the number as a value in an AppWithinMinutes.number object.

(I know I may use tags for this, and it works, but we use tagging for other purposes and do not want to mix this up.)

Now, I want to query the db for the page that has this number. I can get all pages that has an “AppWithinMinutes.number” object like this:

#set ($hql = "select prop from XWikiDocument doc, BaseObject obj, IntegerProperty prop where obj.className='AppWithinMinutes.Number' and doc.space like '%User help%'")
#set ($result = $services.query.hql($hql).setLimit(10).execute())

I don’t know if the above makes sense. But how should I make the query look for a number as well? I’m confused as to what object I should ask the db for, and to be honest I have no idea what I actually get in the “prop” above.

Grateful for clues
/Niklas

See https://extensions.xwiki.org/xwiki/bin/view/Extension/Query+Module#HQueryLanguageExamples , precisely the “Query on XObjects and filtering on XObject property value” example.

Thank you so much @mflorea !