Calculate the number of values selected in a Scaffolding list

Calculate the number of values selected in a Scaffolding list

Scenario

You've built a Scaffolding form, and you'd like to count some of the user entries in a Scaffolding dropdown list. See Create a simple form with Scaffolding macros.

Recipe

Apps

Reporting for Confluence Data Center, Scaffolding for Confluence Data Center

Level

Intermediate

Estimated time

10 minutes

Macros

Report Eval, Report Variable, Text Filter

Suppliers

Stats On Supplier, Variable Supplier

Storage format

You can copy and paste this code into the Confluence Source Editor:

<h3>Description:</h3> <p>In this example, we'll calculate how many times users enter a value in a list.</p> <ac:structured-macro ac:macro-id="39e7e0b6-36e0-40b1-8b24-5b7d900c3c15" ac:name="table-data" ac:schema-version="1"> <ac:parameter ac:name="name">failpass</ac:parameter> <ac:rich-text-body> <table class="wrapped"> <colgroup> <col/> <col/> </colgroup> <tbody> <tr> <th>Test</th> <th>Result</th> </tr> <tr> <td> <div class="content-wrapper"> <ac:structured-macro ac:macro-id="e3381d17-e691-4128-96c5-7b38318a5e0a" ac:name="text-data" ac:schema-version="1"> <ac:parameter ac:name="name">TestNo</ac:parameter> <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter> <ac:rich-text-body> <p> <br/> </p> </ac:rich-text-body> </ac:structured-macro> </div> </td> <td> <div class="content-wrapper"> <ac:structured-macro ac:macro-id="1f5606d4-44bd-4de0-ac2f-4ea0c47ff54b" ac:name="list-data" ac:schema-version="1"> <ac:parameter ac:name="name">result</ac:parameter> <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter> <ac:rich-text-body> <ac:structured-macro ac:macro-id="70fcee09-f455-4ca3-a0fa-73f2e7802e90" ac:name="list-option" ac:schema-version="1"> <ac:parameter ac:name="value">fail</ac:parameter> <ac:rich-text-body> <p> <br/> </p> </ac:rich-text-body> </ac:structured-macro> <ac:structured-macro ac:macro-id="941b9b63-0078-4152-a189-3bd5bb8cf887" ac:name="list-option" ac:schema-version="1"> <ac:parameter ac:name="value">pass</ac:parameter> <ac:rich-text-body> <p> <br/> </p> </ac:rich-text-body> </ac:structured-macro> </ac:rich-text-body> </ac:structured-macro> </div> </td> </tr> </tbody> </table> <p> <br/> </p> <p> <br/> </p> </ac:rich-text-body> </ac:structured-macro> <h3>Result: </h3> <ac:structured-macro ac:macro-id="624344f6-6209-4332-99ca-def940c42760" ac:name="report-variable" ac:schema-version="1"> <ac:parameter ac:name="name">totalFail</ac:parameter> <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter> <ac:rich-text-body> <ac:structured-macro ac:macro-id="62b2ec16-ca70-4b7d-9f88-1feaa6d2154b" ac:name="local-reporter" ac:schema-version="1"> <ac:parameter ac:name="">data:failpass</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="48b25b58-d73e-4606-af81-33711463b548" ac:name="text-filter" ac:schema-version="1"> <ac:parameter ac:name="value">fail</ac:parameter> <ac:parameter ac:name="">data:result</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> </ac:rich-text-body> </ac:structured-macro> <ac:structured-macro ac:macro-id="febe95bf-28ec-4087-8ccb-299309cc6772" ac:name="report-variable" ac:schema-version="1"> <ac:parameter ac:name="name">totalPass</ac:parameter> <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter> <ac:rich-text-body> <ac:structured-macro ac:macro-id="2e300fe0-3c48-4b9c-8c86-0e1bd888ea50" ac:name="local-reporter" ac:schema-version="1"> <ac:parameter ac:name="">data:failpass</ac:parameter> <ac:rich-text-body> <p> <ac:structured-macro ac:macro-id="db1dbc43-1a65-45ad-8b42-87a4399771bf" ac:name="text-filter" ac:schema-version="1"> <ac:parameter ac:name="value">pass</ac:parameter> <ac:parameter ac:name="">data:result</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro> </ac:rich-text-body> </ac:structured-macro> <p>Number of Fails: <ac:structured-macro ac:macro-id="ea2843fe-0a85-4b6d-ad3f-6a2bda75eb96" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">variable:totalFail&gt;size</ac:parameter> </ac:structured-macro> </p> <p>Number of Passes: <ac:structured-macro ac:macro-id="d9281b6c-5984-4bac-a8ce-bc1dec827601" ac:name="report-info" ac:schema-version="1"> <ac:parameter ac:name="">variable:totalPass&gt;size</ac:parameter> </ac:structured-macro> </p> <p>The total number of results is: </p> <ac:structured-macro ac:macro-id="9a2a7719-ab6f-4642-9f83-c90c0f5ea469" ac:name="report-eval" ac:schema-version="1"> <ac:parameter ac:name="format">#</ac:parameter> <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter> <ac:parameter ac:name="">totalresult</ac:parameter> <ac:plain-text-body><![CDATA[%variable:totalPass>size% + %variable:totalFail>size%]]></ac:plain-text-body> </ac:structured-macro> <p> <br/> </p> <p> <br/> </p> <p> <br/> </p> <pre class="syntaxhighlighter-pre"> <br/> </pre> <p> <br/> </p> <p> <br/> </p>

Steps

  1. Create a Scaffolding form as follows:

    1. Create a Table Data macro with the Name parameter set to failpass.

    2. Within the Table Data macro, create a table and insert a List Data macro with the Name parameter set to result.

    3. Within the List Data macro, insert two List Option macros with Value parameters set to fail and pass.

  2. Create a Report Variable macro with the Name parameter set to totalFail.

  3. Within the Report Variable macro, create a Local Reporter macro with the Key parameter set to data:failpass.

  4. Within the Local Reporter macro, create a Text Filter macro with the following parameters:

    • Set the Key parameter to data:result.

    • Set the Exact Value parameter to fail.

  5. Create another Report Variable macro with the Name parameter set to totalPass.

  6. Within the Report Variable macro, create a Local Reporter macro with the Key parameter set to data:failpass.

  7. Within the Local Reporter macro, create a Text Filter macro with the following parameters:

    • Set the Key parameter to data:result.

    • Set the Exact Value parameter to pass.

  8. Create a Report Info macro with the Key parameter set to variable:totalFail>size.

  9. Create a Report Info macro with the Key set to variable:totalPass>size.

  10. Create a Report Eval macro, and enter the following inside its body:
    %variable:totalPass>size% + %variable:totalFail>size%

Macro structure

You can recreate the example in the editor view:

calculate_selected_Scaffolding_options.png