Injecting Parameters with Parameter Injections

This guide will help you get a better understanding of parameter injections.

Suggested Reading

Read these guides first before continuing:

Understanding Parameter Injections

Various Reporting macros support parameter injections, such as Report Variable and Report Eval, just to name a few.

Injecting parameters into a macro means that you can take a parameter of a Supplier and inject the value of that parameter into that macro.

For example, using the Report Variable macro, you can declare a variable with a constant value of "10". But what if you wanted to declare a value that's more dynamic? Let's say you want to declare a variable with a number that's equivalent to the number of characters in the title of the current page.

The keychain for that would be: "content:title > text:size" and will give you the result of "46".

To use that with the Report Variable macro, you will have to "inject" that keychain value into it. You do that by entering %content:title > text:size% into the Value parameter of the Report Variable.

Notice the keychain is surrounded by the "%" character.

Now that the Report Variable macro has been injected with the keychain as its value, you can now use that value with other Reporting-related macros.

Example 1: Showing the Page Title

Let's start with something basic and display the page's title.

  1. Create a Report On macro.

  2. Tick the Injected parameter.

  3. Within the report-on macro, type in "%content:title%".

  4. You should have something like this:



    Which should display this: 
    "Injecting Parameters with Parameter Injections"

Example 2: Showing the Page Title of the Parent Page

Let's show the title of the parent of the current page.

  1. First, create a Report Variable macro.

  2. For the Name parameter, type in "Parent Name".

  3. Now, let's inject the following keychain into the Value parameter:
    %page:parent > page:title%

  4. Create a Report Info macro so we can get the results of the Value from Report Variable.

  5. For the Key parameter, type in "variable:Parent Name".
    (Notice that the variable is called using a keychain using the Variable Supplier.) 

  6. You should have something like this:



    Which should result in this:

    "Intermediate Tutorials"


Example 3: Displaying a Message with Multiple Values from Different Suppliers

Let's display a message that contains several parameter injections.

  1. Start by creating a report-variable.

  2. For the Name parameter, type in "Message".

  3. For the Value parameter, let's type in this text string which includes some injected parameters:
    "Created by %page:creator > user:full name% on %page:creation date > date:dd-MMM-yyyy%"

  4. Now, create a Report Info macro.

  5. For the Key parameter, type in "variable:Message".

  6. You should now have something that looks like this:


    Which should result in this:

    "Created by Ted Mahsun on 18-Sep-2014"
    Â