Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

Enables you to display data that is generated by SIL script in a table, great for reporting.

...

  1. To create a script, go to Confluence Administration > Add-ons > cPrime Tools, and click SIL Manager.
  2. Click the silprograms folder and then New > New file
  3. Create a new SIL file and name it, for example, CollectDescendants.sil like in the image below. 




  4. In the CollectDescendants.sil file that you created write the following script. It represents how the TableScriptMacro uses the standard variables.
    Then click Check and Save.

    Code Block
    include "PageDTO.incl";
    
    PageDTO[] dtos;
    
    if (size(argv) < 2) {
        print("space key and page title are not specified");
        return dtos;
    }
    
    string spaceKey = argv[0];
    string pageTitle = argv[1];
    number page = getPage(spaceKey, pageTitle);
    
    if (page < 0) {
        print("space'" + spaceKey + "' has no page '" + pageTitle + "'");
        
    }
    
    number[] descendants = getPages(page);
    
    for (number pageId in descendants) {
        PageDTO dto; 
        
        dto.id = %pageId%.id;
        dto.author = %pageId%.author;
        dto.title = %pageId%.title;
        dto.created = %pageId%.created;
        dto.updated = %pageId%.updated;
        
        dtos += dto;
    }
    
    return dtos;
  5. Supporting script Page DTO is created. This script contains information about the following columns: ID, Author, (page) Title, Created, and Updated.

  6. You can find more information about managing your SIL Scripts on the SIL Manager page.

2. Creating a TableScriptMacro

...

  1. To add a TableScriptMacro, go to the necessary Confluence page, click Insert more content, and select Other macros > SIL table.



  2. In the displayed dialog, fill out the necessary fields:
    1. Enter the script name that you created.
    2. Enter the names for the columns.
    3. Enter the input - space key and the page name where you want to display the variables.
    4. Define the separator. In our case we used comma as a separator, and you can define another symbol. For instance, in cases where a page contains commas in the name, you might want to use period as a separator. For the TableScriptMacro, the separator is applied to both columns and input fields.



    5. If the transposed checkbox is selected, the table columns will be transposed.



  3. Click Save to create a TableScriptMacro.



...

You have created CollectDescendants.sil script and a TableScriptMacro that is associated with this script.

Result

Every time you that update a page, the macro will display data generated by the selected SIL script in a table.

...