---+ QUERY -- get the value of meta-data Uses the query syntax described in [[%SYSTEMWEB%.QuerySearch][QuerySearch]] to get information about meta-data from one specified topic. * supports formatted access to formfields and other meta-data in topics using the same syntax as is used in =IF= and =SEARCH= statements, * gives access to *all* meta-data, including that added by extensions, * supports reporting values using JSON and other standards, simplifying the retrieval of meta-data for REST applications, * replaces the =[[VarFORMFIELD][FORMFIELD]]= macro for most applications. See !QuerySearch for more details of how to write queries ---++ Parameters | *Parameter* | *Description* | | ="item"= | The meta-data to query | | =style= | set the output format (see below) | | =rev= | operate on the given version of the current topic. Note that this will _only_ affect simple queries that refer to the current topic, such as =form.name=. More complex queries that use searches or indirection to refer to other topics always use the *latest* version of those topics. | ---++ Examples <pre class="tml"> Get the name of the form in the current topic: %<nop>QUERY{"form.name"}% Get the value of the 'Firstname' form field in the current topic: %<nop>QUERY{"fields[name='Firstname'].value"}% Get the value of the 'Firstname' form field in the current topic (shorthand version): %<nop>QUERY{"Firstname"}% Get a list of all the names of attachments on the topic '%SYSTEMWEB%.DocumentGraphics': %<nop>QUERY{"'%SYSTEMWEB%.DocumentGraphics'/attachments.name"}% Get configuration setting {NameFilter}: %<nop>QUERY{"{NameFilter}"}% </pre> Plain strings (such as field values) are returned _without_ quotes. Simple arrays of scalars are also returned without quotes, in a comma-separated list (beware of values that contain commas!). More complex data structures (e.g. arrays of hashes) will only be returned if =style="perl"= or =style="json"= are set - else will return a string containing 'undef'. You can make the macro generate different output formats using the =style= parameter: * =style="perl"= - generates values as Perl code strings generated by running through CPAN:Data::Dumper * =style="json"= - generates values as JSON strings, suitable for reading by browsers. Only some configuration settings are available via QUERY: %FORMAT{"%QUERY{"{AccessibleCFG}"}%" type="string" format="=$item=" separator=", "}% %STOPINCLUDE% ---++ Related [[VarMETA][META]] [[QuerySearch][QuerySearch]]
This topic: System
>
Category
>
UserDocumentationCategory
>
Macros
>
VarQUERY
Topic revision:
15 Mar 2026,
UnknownUser
(raw view)
Copyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki?
Send feedback