Document Formula

Written By Jessica Moore (Super Administrator)

Updated at August 19th, 2026

Document formulas
Below are the general rules for building formulas in the SchemeServe Document area (Template Editor / endorsement wording / display logic). This is the “same thing” as the rating-file rules, but tailored to how documents actually evaluate fields, formatting, and HTML/CSS.

General rules for SchemeServe document formulas

1) Know the three “contexts” you can write formulas in

Document logic usually appears in one of these places:

  • Inline token formulas wrapped in ## ... ##
    Used to print values or run calculations directly in the document body.
  • Display/hide logic inside HTML/CSS, typically:
    style="display:##IF(...,'','none')##"
    Used to show/hide paragraphs, table rows, divs, etc.
  • Non-## DisplayIf blocks (used when text formatting must be preserved):
    <DisplayIf Formula="..."> ... </DisplayIf>

Especially useful for multi-paragraph textbox content that collapses into one line when pulled via ##...##.
 


2) Inline formulas must be wrapped in ##

If you want the system to evaluate the expression and print the output, you must wrap it:

##IF([Record.Type]='Renewal','Renewal','New Business')##

 

Example — Document title to cover multiple records/status

Use the formula below when the document heading needs to change automatically according to [Record.Type] and [Record.Status].

##IF([Record.Type] = 'First Premium' AND [Record.Status] = 'On Cover', 'POLICY SCHEDULE', IF([Record.Type] = 'First Premium' AND [Record.Status] = 'Quotation', 'QUOTATION', IF([Record.Type] = 'Renewal' AND [Record.Status] = 'Quotation', 'RENEWAL QUOTATION', IF([Record.Type] = 'Renewal' AND [Record.Status] = 'On Cover', 'RENEWAL POLICY SCHEDULE', IF([Record.Type] = 'Adjustment' AND [Record.Status] = 'Quotation', 'MTA QUOTATION', IF([Record.Type] = 'Adjustment' AND [Record.Status] = 'On Cover', 'MTA POLICY SCHEDULE', IF([Record.Type] = 'Adjustment' AND [Record.Status] = 'Cancelled', 'CANCELLATION', 'QUOTATION')))))))##
Record type Status Output
First Premium On Cover POLICY SCHEDULE
First Premium Quotation QUOTATION
Renewal Quotation RENEWAL QUOTATION
Renewal On Cover RENEWAL POLICY SCHEDULE
Adjustment Quotation MTA QUOTATION
Adjustment On Cover MTA POLICY SCHEDULE
Adjustment Cancelled CANCELLATION

Fallback: if none of the conditions match, the formula returns QUOTATION.


3) Use square brackets for field references

All dynamic fields are referenced using [ ... ].

Common examples:
[Record.Type], [Record.Status], [Record.CreatedDate]
[Policy.InceptionDate], [Policy.OriginalInceptionDate]
[Client.ClientId], [Agent.AccountRef][QuestionID_Value], [QuestionID_Cover], [QuestionID_DateValue]


Use the correct suffix

This is the the most common mistake when building a formula

 

4) Use the correct suffix (_Value, _Cover, _DateValue, _ResultBefore)

Same idea as rating files, but with some doc-specific gotchas:

Suffix/Modifier

_Cover Numeric/Money - e.g. the amount entered in a Calculation question
_Value Text - e.g. the answer Yes/No
_Fee Numeric/Money - e.g. the Fee you've set some rows above in your rating file
_Result Numeric/Money - e.g. the result of your total Premium 'TotalPremium_Result'
i.e the obtained result of a % applied to £XX Sum Insured
_DateValue Date
_CoverBefore Pull through the previous record´s answer on a calculation question
_Rate Numeric/Money - e.g. the Rate you've set some rows above in your rating file
 
 

 


5) Text needs quotes; numbers don’t

Text comparisons: "Yes", "Renewal", “On Cover”
Numeric comparisons: 0, 1000, 30.5
 


6) Dates: formatting and comparisons use different techniques

A) Comparing against a fixed date
Use hash-wrapped dates:
##IF([Policy.InceptionDate] >= #2021-07-12#,1','0')##

B) Printing a date in a specific format
Use .ToString(...):
##[Policy.InceptionDate].ToString("dd MMMM yyyy")##

C) Adding/subtracting time
Use .AddYears(), .AddDays(), etc.:
##[CompletionDate_DateValue].AddYears(10).ToString("dd MMMM yyyy")##
 


7) Converting numbers into readable formats (currency, decimals, percentages)

You’ll commonly format numeric outputs using .ToString(...):
Currency (no decimals):
##[PLIndemnity_Cover].ToString("C0")##

Currency (2 decimals):
##[BasicPremium_Result].ToString("C2")##

Number with 1 decimal:
##(([TotalCommission_IndexLevel0_Result]/[TotalPremiumNet_Result])*100).ToString("N1")## %
 


8) Show/hide content using display:##IF(...)##

This is the standard pattern:
<tr style="display:##IF([Record.Type]='Renewal','','none')##">

How it works:

IF true → return '' (blank) → normal display
IF false → return 'none' → hidden
 


9) Multi-field “one line address” pattern: build strings safely

When concatenating fields, protect optional lines by checking if they contain real text:

##[AddressLine1]## ##IF([AddressLine2].Replace(' ','').Length>0, ', ' + [AddressLine2], '')## …
 
 

10) Tables and MP: know when you need row indexing or GroupBy

To pull a specific row:
##[Table_Name_Row#0_Value]##

For MultiPage (MP) documents, use [GroupBy ...] ... [/GroupBy] and MP fields like:
##[MP_RowNumber]## (inside groupby)
##[MP_SystemID_Cover]## (combined totals outside groupby, with limitations)
 


11) Keep document formulas readable and maintainable

Best practice in templates:
Keep formula blocks short and repeatable
Prefer hidden fields in rating when the doc logic becomes complex (docs are for presentation)
Use consistent patterns for display toggles ('' vs 'none')