Create and print custom formats with Print When and If Statements

When creating a custom format, there may be situations when you don't want something to print unless a specified criteria is met, or you want to print something else when the specified criteria is or isn't met. The Practice CS Custom Formatter provides 2 tools you can use to control what prints on the output.
  • Print When
    formulas
  • If Statements

Print When formulas

A
Print When
formula controls whether an item will print on the document or not. The item will print only if the
Print When
formula is set to
True
, and won't print if the
Print When
formula is set to
False
.
  • You can apply
    Print When
    formulas to individual fields or whole sections of the format.
  • The basic structure of a
    Print When
    formula is: print this item only if [variable] [operator] [value].
  • Invoice Example:
    Print the adjustments amount only if it's not equal to 0.
    • The expression to use for this:
      [AR Activity Adjustments(Key(Client), Detail Line Date From(1), Detail Line Date To(1)) <> 0]
    • Everything before the
      <>
      operator is the variable that represents the adjustments. You don't need to know how to build this variable since it's already in the OutputValue Formula screen. Double-click the field to open the OutputValue Formula screen. You can then highlight and copy the variable.
    • The operator
      <>
      which represents
      not equal to
      . Other operators include:
      • =
        : equals
      • <
        : less than
      • <=
        : less than or equal to
      • >
        : greater than
      • >=
        : greater than or equal to
    • Finally, the value against which the variable is compared is 0.
  • To add the
    Print When
    formula to a field:
    1. Select the field to highlight it.
    2. In the Properties pane, go to the
      PrintWhen
      attribute in the Suppression section.
    3. Select the
      PrintWhen
      field, then Browse
    4. Enter the formula in the center section of the
      PrintWhen
      Formula window.
    5. Select
      OK
      .
    6. Because we are removing the value of the adjustments amount when its value is 0, we want to also remove the label before the value field if the adjustments amount is 0. To do this, repeat all the previous steps except highlight the field that contains the label instead of the field that contains the variable.
    7. Finally, if the adjustments is 0, and neither field prints, it will leave an empty space. To avoid this, set the
      CanShrink
      attribute in the Behavior section of the properties to
      True
      for both fields.
  • To add a
    Print When
    formula to a section:
    1. Follow the instructions for adding a
      Print When
      formula to a field, except select the header.
    2. In the following example, the
      Detail
      section prints a line for each WIP transaction in each engagement. We don't want to print the line if the hours is 0.
    3. To effect this, select the header of the Detail section which shades the header and then add a
      Print When
      formula in the properties of the header as described previously for an individual field.
    4. The
      Print When
      formula is:
      [Billing Decision units closed(Billing Decision) <> 0]
      .
    5. Everything before
      <>
      is the variable for the hours on an individual transaction.
    6. Because the group repeats each transaction, it's not necessary to set the
      CanShrink
      variable as we did for individual fields.

If Statements

If Statements
are an another way to control what will print on the format.
  • The primary differences between a
    Print When
    formula and an
    If Statement
    are:
    • A
      Print When
      can only suppress the printing of an item.
    • An
      If Statement
      can print something different if the condition is false.
    • If Statements
      can only be used for individual fields.
    • The
      Print When
      only suppresses whether the item is printed. However its value is still included in any subtotals and totals based on the variable. If the value of a variable is suppressed by an
      If Statement,
      then that value isn't included in subtotals and totals based on the variable.
  • The basic structure of an
    If Statement
    is:
    IF([variable] [operator] [value], [what to print if true] , [what to print if false)]
    .
  • The
    If Statement
    could've been used in place of the
    Print When
    on the adjustment amount. An example would be:
    [IF(AR Activity Adjustments(Key(Client), Detail Line Date From(1), Detail Line Date To(1)) <> 0, AR Activity Adjustments(Key(Client), Detail Line Date From(1), Detail Line Date To(1)), "")]
  • Practice CS includes a tool to help you build
    If Statements
    . Follow these steps to create an
    If Statement
    .
    1. Double-click the field where you want to insert an
      If Statement
      to open the
      OutputValue formula
      screen.
    2. Select the
      If Expression
      tab.
    3. Find the variable to test in the variable tree. In this example the variable is
      Client
      ,
      A/R
      ,
      Activity
      ,
      All Adjustments
      .
    4. Select and drag it into the
      If condition
      field.
    5. Select an
      Operator
      . In this example, the operator is
      <>
      (not equal to).
    6. Enter the value to compare with into the area marked
      Enter the criteria for the condition here
      . The value can be another variable, a number, or an alpha expression. In this example, we're testing the variable for a value of 0, so we enter 0 in the field.
    7. In the
      Then print
      field, enter what to print if the
      If
      condition is true. In this example, the value is the field being tested,
      All Adjustments
      .
    8. In the
      Otherwise print
      field, enter what to be print if the
      If
      condition is false. In this example the value is blank—nothing is entered here.
    9. Select
      Apply
      to have Practice CS build the
      If Statement
      .
    10. Select
      OK
      to save the
      If Statement
      in the field on the layout.