Administrator Guide 2017
Adding Special Merge Fields to a magic5 Word Document report
  • Repeating items with a fixed number of rows


    For a known number of repeating areas, iterations need to have a suffix of ___n (ie 3 x '_').   The first occurence has an implicit suffix of ___0 (even if not entered), whilst subsequent iterations have ___1, ___2, etc.
  • Repeating sections or an unspecified number of rows


    Repeating sections or an unspecified number of rows in a magic5 table can be output by entering the unique name in each position (eg Word table cell) and entering the following as a separate mergefield (see step 3) at the start of the repeating area:
    RangeStart:[unique name of section or table]
    and the following at the end
    RangeEnd:[unique name of section or table]

    For example, the following is from a table in a Word document into which the data from a repeating section called fuelSources is to be entered.  The first template item has a unique name of fuelSource, the next fuelSourceLocation and the last fuelCurrentControlMeasure.
  • Repeating sections of Events

    A table can also contain all the events of a particular event type for the entity in question. For instance, a correspondence with a location might be kept in an audit trail with an event type of CORRES that has an internal id number of 9 (ask magic5 support for this information).  This can be displayed in a table in the same way as above using:
    RangeStart:$EVENTOUTPUT_[entity]_[internal event type number]
    and then closed using
    RangeEnd:$EVENTOUTPUT_[entity]_[internal event type number]

    For example: RangeStart:$EVENTOUTPUT_LO_9   
  • Repeating sections of Entity Lists

    A table can also contain all the items in a particular list for the entity in question. For instance, a correspondence with a location might be kept in a list that is an attribute of the location  (ask magic5 support for this information).  This can be displayed in a table in the same way as above using:
    RangeStart:$LISTOUTPUT_[entity]_[name of entity attribute containing list id]
    and then closed using
    RangeEnd:$LISTOUTPUT_[entity]_[name of entity attribute containing list id]

    For example: RangeStart:$EVENTOUTPUT_LO_9   
  • Conditionally remove a row


    In a table, a row can be conditionally removed using the statement
    $delTR_[unique name of a multiple choice item]_[multiple choice answer]
    This can be positioned anywhere in the conditional row. 
    A repeating item (as described above) needs to replace the underscore ("_") with a hyphen ("-")
    $delTR-[unique name of a multiple choice item including suffix]_[multiple choice answer]
    If the condition is too long for the mergefield, it is possible to create the condition as a formula in the Additional Attributes box of the Word Template and inset it into the document as :
    $delTRX_[formula name]
    NB hyphen does not work here

    NB to remove a row, create a formula as rowCount;[table name];lt;1 which could be used for deleting a table as well
  • Conditionally remove a column


    In a table, a column can be conditionally removed using the statement
    $delTC_[unique name of a multiple choice item]_[multiple choice answer]
    This can be positioned anywhere in the conditional row. 
    A repeating item (as described above) needs to replace the underscore ("_") with a hyphen ("-")
    $delTC-[unique name of a multiple choice item including suffix]_[multiple choice answer]
    If the condition is too long for the mergefield, it is possible to create the condition as a formula in the Additional Attributes box of the Word Template and inset it into the document as :
    $delTCX_[formula name]
    NB hyphen does not work here
  • Conditionally remove a table


    A whole table can be conditionally removed using a similar syntax of
    $delTABLE_[unique name of a multiple choice item]_[multiple choice answer]

    $delTABLE-[unique name of a mandatory item within repeating area including suffix]-[multiple choice answer]

    (note the use of hyphen instead of underscore when using a repeating item).
    If the condition is too long for the mergefield, it is possible to create the condition as a formula in the Additional Attributes box of the Word Template and inset it into the document as :
    $delTABLEX_[formula name] or $delTBX_[formula name]
    NB hyphen does not work here
  • Remove an empty row or table


    $delTABLE and $delTR can also be used to remove a table or a row if when an item contains no data (ie is 'null') using the syntax

            $delTABLE_[unique name of item]   or   $delTR_[unique name of item]  

    or   $delTABLE-[unique name of item plus iteration suffix]   or $delTR-[unique name of item plus iteration suffix]

  • Output all findings in a section


    Output all Findings, Follow-ups and Timescales plus any text entry or photo items within a section using the syntax
    SectionFindings_[unique name of section]
    To omit the text entry items use
    SectionFindingsNoComments_[unique name of section]
    To be more complicated still, use RangeStart:$ACTIONPLAN followed by fnd_text, fup_text, fup_timscale and finished with RangeEnd:$ACTIONPLAN


  • Use a tick


    Ticks be set up using the syntax
    $tick_[unique name of template item]_[answer to trigger the tick]
    eg $tick_ClearWalkway_Yes
    where the answer is in text (ie not the id)

    NB. $tick is now $tickBox

    NB. the unicode for a tick box is 0252 and is available in Wingdings if you need to use a symbol and a SHOWIF bookmark. 
    This is sometimes necessary if the text of a list item is too long for a mergefield box.  It might be possible to copy this symbol  ü
  • Use a cross


    Similarly, a cross can be set using the syntax
    $cross_[unique name of template item]_[answer to trigger the cross]
    eg $cross_ClearWalkway_No
    NB. $cross is now $crossBox

  • Insert a formula


    Create a formula in the Additional settings text box in a Word template list item in the format
            [name used for formula]=[conditionType];[uniqueName or attribute or id];[testType];valueToTest
    This is likely to be similar to a Display Condition.

    Insert this into the merge field as :
    $FormulaX_[name used for formula]

    This is very useful for handling unique names with underscores and very long names that won't fit into a Word bookmark or merge field.