Dashboard counter for App Within Minutes Entries

I would like to display a dashboard counter for pages in my app Within Minutes (AWM).

I have a AWM-Class with a property:

* Title (<AWMDATA>: Static List)

Now I want to count how many pages have the given entry VALUEfromAWMDATA.
I’m not able to code the xwql-statement so far…

Something like this:

{{velocity}}
#set ( $count = 0 )
  #foreach ($item in $services.query.xwql("select <?>.<AWMDATA> from XWikiDocument as <?>").execute())
    #if ( $item.contains(<VALUEfromAWMDATA>))
      #set ( $count = $count + 1 )
    #end
  #end
$count Pages with <VALUEfromAWMDATA>
{{/velocity}}

Try this.

{{velocity}}
#set ($className = 'YourAWMClass')  # Replace with your actual AWM class name
#set ($propertyName = 'Title')       # Replace with your actual property name
#set ($propertyValue = 'VALUEfromAWMDATA')  # Replace with the value you're looking for
#set ($query = "from doc.object(${className}) as obj where obj.${propertyName} = :value")
#set ($count = $services.query.xwql($query).bindValue('value', $propertyValue).execute().size())

$count Pages with $propertyValue
{{/velocity}}

Don’t forget to change your class name.

1 Like

Alternatively, instead of setting className and propertyName with their values as separated variables, you can combine them into one query statement. Depends on your preferences and whether are you planning to change query afterward.

1 Like

Thanks. That was not running.

[[1,59] expecting: ')'

There is a problem with some “-” in my class name. It is something like this:
Page.Your-AWM-App.Code.Your-AWM-AppClass

ChatGPT found out that I shout use additional ‘’ in doc.object('${className}')

What finally worked was:

{{velocity}}
#set ($className = 'YourAWMClass')  # Replace with your actual AWM class name
#set ($propertyName = 'Title')       # Replace with your actual property name
#set ($propertyValue = 'VALUEfromAWMDATA')  # Replace with the value you're looking for
#set ($query = "from doc.object('${className}') as obj where obj.${propertyName} = :value")
#set ($count = $services.query.xwql($query).bindValue('value', $propertyValue).execute().size())

$count Pages with $propertyValue
{{/velocity}}

Thanks for your help!