projectdoc Toolbox

Shows how to render the value of a document property with a display macro. There are actually three variants of this macro that we are discussion in this short article.

Audience
Type
Level of Experience
Contents

The Display Property Macros allow to reference another projectdoc Document and display on of its document properties. The simplest version of these macros is the Display Document Property Macro which will render a single value. There are more members in this family.

This short article introduces a simple macro for displaying property values and two of its siblings.

Simple Use Case: Display a Property Value

The Display Document Property Macro allows to add a link to a Confluence page and, in case the page is a projectdoc Document, allows to select a property name to render the value for that property.

Render a Property Value

 

Suppose there is a document for an organization named Green Documentation Organization.

To render the organization's website, use the Display Document Property Macro like this:

The property value is rendered as a link since the value is actually a link pointing to https://greendocs4u.eu/.

Do not click the Add Link checkbox! 

The macro will even not allow to override the link address so that the link https://greendocs4u.eu/ does point to https://greendocs4u.eu/

Display Property Value from a referenced Document

The use case for the Display Document Property Ref Macro is a little more complex. It allows you to specify a document where a property references another document which provides a property you want to render. Seems complicated? Well, let's look at an example!

Rendering a Property from a referenced Document

 

Suppose you add a person document for Gabriella Green. The idea is that every person working for an organization should have the organization's website as default.

So this is the new version of the organization document:

And this is the document for Gabriella Green:

While the email address is for Gabriella personally, the website of the organization is rendered for her website.

Here is the Display Document Property Ref Macro in the macro editor:

Because Documents is empty the macro points to the Organization property in the same document. Following the link to the organization, the macro picks the value of the organization's Website property.

In case the website for the organization changes, the change will be applied automatically to the Website property of Gabriella's document.

Issue with the Documents Parameter

 

Due to an issue with the Documents parameter, there is no autocomplete. See PDAC-1543 - Getting issue details... STATUS for details

Concatenate Property Values from two different Documents

The use case for the Display Document Property Ref Concat Macro is only one small step further. It allows to fetch two property values from two different documents and render them together. Is there actually a use case for this macro? Here is the example:

Rendering two Property Values from two Documents

 

For this use case we add a telephone number to get in touch with the Green Documentation Organization.

The Phone Stem property provides the base phone number where employees add their extension number. For Gabriella this looks like this:

The configuration of the Display Document Property Ref Concat Macro in the macro editor looks like this:

The rendered document of Gabriella:

Both properties, Phone and Website, use the Organization reference to fetch information Phone Stem and the Website from the organization.

Summary

In this tip we managed to render a property from a document. 

First the Display Document Property Macro simply renders a property from the referenced document.

Then the Display Document Property Ref Macro allows to render a property value from a document that is referenced by a property. In our case this property was a property of the local document (the document with the macro). And this is the typical use case.

Finally the Display Document Property Ref Concat Macro allows to render two property values from two different documents. While the use case may seem a bit abstract, the macro is actually quite handy for concatenating values. Again the typical use case is that one property value is on the local document.

References

The following topics are discussed in this article.

Display Document Property Macro
Renders the value of a property of a document.
Display Document Property Ref Macro
Displays a document property from a referenced document.
Display Document Property Ref Concat Macro
Displays a single property of a document that is referred by a property of another document and concatenates it with the value of a local property.

Resources

Here are more resources related to the topic of this article.

Name Short Description Doctype
projectdoc documents typically provide a property named 'Parent Property'. This property refers to a logical parent. This tip shows what this is all about.
topic
Show how to use the Name List Macro to render links to glossary terms.
topic
If you want to list a reference to a document with name and short description, use the Display Properties Macro. If you specify no property names, it defaults to Name and Short Description.
topic
Renders a template with property references.
macro
Renders the value of a document property as an image. The property value is required to an URL that points to an image.
macro
Renders the value of a document property as a link with an alternative label.
macro
Renders the list value of a document property.
macro
Renders the property of the parent document, if it has the same doctype.
macro
Renders a space property value.
macro
Renders a space attribute value.
macro