More advanced documents

From SchemeServe Help
Jump to: navigation, search

Introduction

WARNING: This is an advanced topic intended for expert users.
If you are not comfortable editing raw HTML, seek further assistance from your web designer.
A knowledge of basic programming concepts is also advisable.

With SchemeServe is is possible to augment dynamic document templates with conditional and mathematical operators for richer, more dynamic results. To do this, you should use admScript.


All about admScript

For more information on the language that powers conditional operations in SchemeServe Documents and Reports, see admScript Language Reference. You will find a complete list of possible operators and syntax.

For specific examples of this syntax in action with respect to document templates, read on.


Examples of admScript in Documents

Most seasoned SchemeServe users will be familiar with the syntax used for embedding the answers to Case questions into dynamic documents. Simply stated, the SystemID of the question required is entered into the document body, within square brackets wherever you require that value to be substituted at the time the document is generated.

So the following HTML:

<p>Total premium is: £[TotalPremium_Result]</p>

Might become at the time the document is generated:

 Total premium is: £12,789.11

This syntax persists even when using conditional operators (as in the next section below), you must always use square brackets even within conditional operators and functions.

However, to use conditional admScript, you must prefix and suffix your script with ##

A block of code might therefore be in the following format

##  code  ##


The next step: the IF operator

In some documents, it might be desirable to output sections of HTML, or simple phrases and values, only in response to other values or ranges of values.

This is possible thanks to the admScript conditional operator, IF.

IF responds to the result of a boolean operation by outputting the first of two values if true, or the second if false. So it typically looks a bit like this...

IF(condition, "This is the value to print when the condition is true", "This is the value to print when the condition is false")

Now for some practical examples...


Example 1: Deposit required on large premiums

On a scheme where flexible credit terms are normally offered, you might like to require a 10% deposit when a premium is greater than £10,000.

To do this, you could use:

<p>We require a 10% deposit on premiums greater than £10,000.</p>
<p><strong>  ## IF([TotalPremium_Result] > 11000, "Deposit required.", "Deposit NOT required.") ##  </strong></p>

Notice the Answer value [TotalPremium_Result] is surrounded by square brackets. You must always surround Answer values with square brackets, even inside conditional statements.

The result of the above, when Total Premium is £11,000 will be:

We require a 10% deposit on premiums greater than £10,000.
Deposit required.

Otherwise, the result would be:

We require a 10% deposit on premiums greater than £10,000.
Deposit NOT required.


Example 2: Basic maths

You might extend the example above to actually output the exact deposit required. For example:

<p>We require a 10% deposit on premiums greater than £10,000.</p>
<p><strong>  ##  IF([TotalPremium_Result] > 11000, "Total deposit payable: £" + ( [TotalPremium_Result] * 0.1 ).ToString("C2"), "No deposit required.")  ##  </strong></p> 

The result of the above, when Total Premium is £11,000 will be:

We require a 10% deposit on premiums greater than £10,000.
Total deposit payable: £1,100.

Otherwise, the result would be:

We require a 10% deposit on premiums greater than £10,000.
Deposit NOT required.

For more advanced maths usage, consult the admScript Language Reference.

Example 3: Cover included or not

Instead of printing the exact sum insured/assured for a specific cover, you might like to state simply whether it is 'included' or not. You could do this as follows:

<p>Extended Glass Cover:</p>
<p><strong>  ## IF([GlassCover_Cover] > 0, "Cover INCLUDED", "Cover NOT included.")  ##  </strong></p> 

The result of the above, when Glass Cover is greater than zero will be:

Extended Glass Cover:
Cover INCLUDED

Otherwise, the result would be:

Extended Glass Cover:
Cover NOT included


Example 4: Endorsements included or not

As with Example 3 above with Cover items, you might like to mark next to each endorsement in your schedule or terms documents whether it is 'included' or not. This is very useful for long endorsements that would span many pages and could not be stored in the endorsement library (there is a character limit of 8000 characters).

IMPORTANT: At time of writing it is not possible to determine the SystemID of an endorsement easily.
To do so, login to SchemeServe and navigate to Admin > Endorsements.
View the Source of the page and examine the HTML.
Find the endorsement you are interested in and examine the call to editEndorsement() to find the SystemID.

The syntax is a little more complicated than it would be with other items but is listed below:

<p>Smokers Endorsement</p>
<p><strong>   ## IF([ENDORSEMENTLIB_ID_1874].Length > 0, “APPLIES”, “DOES NOT APPLY”) ##   </strong></p> 
<p>The full terms of this endorsement will follow below.</p>

The result of the above when the endorsement is included will be:

Smokers Endorsement
APPLIES

Otherwise, the result would be:

Smokers Endorsement
DOES NOT APPLY


An important note about user-added endorsements:

If you allow your staff to add endorsements manually to policies via the Endorsements tab on the View Case screen, you will need to extend the above example to check for BOTH the possible automatically added endorsement and the manually added one, as follows. The variable prefixed with 'UQ' is the manually added endorsement.

<p>Smokers Endorsement</p>
<p><strong>   ## IF([UQENDORSEMENTLIB_ID_1874].Length > 0 OR [ENDORSEMENTLIB_ID_1874].Length > 0, “APPLIES”, “DOES NOT APPLY”) ##   </strong></p> 
<p>The full terms of this endorsement will follow below.</p>


See also

For more advanced examples, consult the admScript Language Reference.