Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

RtReports

Advanced iterator expression building techniques

  • Last UpdatedJan 24, 2023
  • 3 minute read

Set the current context for multiple elements

You can use an iterator expression to set the current context of the source expression for multiple dynamic drawing elements in a section.

Only source expressions to the specific data elements in the data journal is required for the nested drawing elements within a section that uses an iterator expression.

In this example, the iterator expression used in the parent section drawing element sets the current context to the UnitBatchJournal element in the data journal. You can create a table within a section element for the UnitBatchJournal element that lists the PIUnitName, Start Time, End Time, and Duration for each UnitBatchJournal element that is included in the report.

  1. Within the section element set to generate a report section for every UnitBatchJournal seen in the example in the topic Iterator expressions in dynamic drawing elements, click Insert > Table.

  2. Select the Table element and click Insert > Table Row to insert a table row element. Repeat this step to insert a second table row element.

  3. Insert four table data elements within each table row element. Click Insert > Table Data.

  4. For the first table row element, insert text elements for each table data element. Click Insert > Text to add the text elements and name them PIUnitName, StartTime, EndTime, and Duration.

    You now point to the data journal elements that will be used to populate the format template table data elements.

  5. For the second table row element, add a data element to the first table data element. Click Insert > Data.

    The Data Edit window opens. Leave this window open.

  6. In the Journal pane, navigate to the PIUnitName from the UnitBatchJournal data journal element, and drag and drop it into the Source field in the Data Edit window.

    The editor automatically detects the iterator expression from the section drawing element, uses that as the parent context for the dynamic drawing element's current context, and inserts a source expression for the data element with a relative file path to the data journal object.

  7. Insert a time element in both the second and third table data elements of the second table row element. Click Insert > Time.

    The Time Edit window opens. Leave this window open.

  8. For the second table data element, drag and drop the StartTime element from the UnitBatchJournal element in the data journal into the Source field of the Time Edit window.

  9. For the third table data element, drag and drop the EndTime element from the UnitBatchJournal element in the data journal into the Source field of the Time Edit window.

  10. For the fourth table data element of the second table row element, insert a duration element, and set the Source field of the Duration Edit window to the Duration element from the UnitBatchJournal element in the data journal.

The table in the generated report displays the PIUnitName, StartTime, EndTime, and Duration, and this table will be reproduced within each section for each UnitBatchJournal element that is created in the data journal when the data template is tested or generated against the data context.

Add one or more operators

When you use an iterator expression, you can include one or more operators. Operators for iterator expressions are added in the same way that you do for source expressions.

For more information about expression operators and syntax, see Source expressions in dynamic drawing elements.

In this example, operators added to the iterator expressions filter the data that is included in the report. You add a single operator to the iterator expression for the section element to filter for results by name. Then you add additional operators to dynamic drawing elements to locate and include report data within each section element result.

  1. Within a section element, in the Iterator field of the Section Edit window, enter the expression

    BatchJournal/UnitBatchJournals/UnitBatchJournal/SubBatchJournals/SubBatch
    Journal[SubBatchName='Charge']

    and click OK.

    The iterator expression filters for all SubBatchJournal nodes with the SubBatchName of Charge.

  2. Within the section element, insert a table element. Click Insert > Table.

  3. In the Table Edit window, select two rows and six columns.

  4. Add one text element to each of the first table data elements in the first table row element. Name the text elements Tag Name, Average Value, Minimum Value, Minimum Time, Maximum Value, and Maximum Time.

  5. Select the second table row element, right-click and select Property. Click the Expressions tab.

    1. In the Iterator field, enter the expression:

      BatchJournal/UnitBatchJournals/UnitBatchJournal/JournalEvents/JournalEvent[Name='Test' and SequenceEntries/JournalEntry/Results/Result/Label='Summary']

      and click OK.

    2. Insert the appropriate dynamic drawing elements in the rest of the table data elements in the second table row element using the relative source expressions to point to the data journal objects within the JournalEvent element.

      TitleResults for “How to create a CRG?”Also Available in