projectdoc Toolbox

Using functions to run searches with the projectdoc Toolbox.

Type
Level of Experience

This tip shows the use of search functions in queries based on macros of the projectdoc Toolbox for Confluence.

Search functions provide values to pass into searches that are dependent on the context. In this tip you will learn how to refer to the current user and the current date.

Journals

For this short introduction of search functions our use case is journals. Suppose Jane and John want to work together and share their professional journals. Each journal is organized in years and days. Each day is a page in the year journal. Each day page collects events the journal owner wants to remember. Jane and John also use a common set of subjects, categories, and tags to organize their events.

 

The free extension projectdoc Developer Diaries provides the blueprints to run journals.

Please note that this doctype add-on requires the projectdoc Toolbox and the free Core Doctypes to be installed.

User Function

Suppose Jane and John use the same view on their work. They craft a page with a couple of display tables and some links to sites that are currently interesting for their work. This page should also collect a number of days from the current user's diary.

This is what the Display Table Macro looks like in the macro editor.

Since every page has the user's full name as the value of the Author property, the currentUser function can be used to render the full name (by the use of the "fn" argument) and compare it in the search with the property value.

 

For more information on date functions and it use of formats and increments, please refer to User Functions in Search Tips.

 

In case you need to step in your team members shoes use Remote Control Feature. Remote Control allows you to override parameters of a referenced page.

In our use case you would need to override the Where parameter:

  1. Add the identifier "events" to the Display Table Macro
  2. Use the Wiki Link macro
    1. Reference this page (the page where the Display Table Macro is on)
    2. Add a label (e.g. "Jane's view")
    3. Add as Request Parametersevents:where=$<Author>=[Jane]

The tip Remote Control shows how to use the feature in more detail.

Date Function

Now let's assume that we only want to show the events of the last week.

$<Date§> >= ${now(-1w)}

The Date property stores the date of the day. To make it comparable to match in a search, you need to use the normalized form. Therefore refer to the artificial property Date§.

The date function now refers to the current date. To define a period of one week to now use -1w (w for week). If the date of the day is not older than one week, it will be part of the result set.

 

Prior to version 4.1 of the projectdoc Toolbox the abbreviated form of the function call was not supported. If you are using an earlier version, please specify your function call like this:

$<Date§> >= ${now("", "-1w")}

The Where parameter now has the value of

$<Author>=${currentUser("fn")} AND $<Date§> >= ${now(-1w)}
 

For more information on date functions and it use of formats and increments, please refer to Date Functions in Search Tips.

More functions?

For a list of supported search function, please refer to Supported Functions in Search Tips.

It is also possible to define ranges easily (Using Date Ranges in Search Tips):

Date§: [${now(-6w)} TO ${now(-4w)}]

Summary

This short tip showed the use of two search functions:

  1. currentUser
  2. now

These functions allow to define queries that are dependent on the current user and the current date.

Resources

Links to related information.

Search Tips
Tips on specifying search queries for Lucene. This also applies to projectdoc's query macros.
Remote Control
Supports Remote Controlled Documents by making parameters accessible via request parameters.
Display Table Macro
Lists references to projectdoc documents in a table. Allows to select document properties for columns. Also non-list representations are provided.