ScreenMath Element
The ScreenMath element is useful in screen rules and transaction configuration to perform calculations, evaluate expressions, and provide information to set field values and conditionally impact field visibility and access resulting from UI events. Its source of information is the screen's or transaction's fields, data from the primary entity, and data retrieved from the database via SQL statements. The following list contains some characteristics of ScreenMath:
-
There can be only one <ScreenMath> structure within the rule.
-
There can be multiple <Math> sub-structures within a <ScreenMath> structure with each sub-structure identified by a unique name in the ID attribute.
-
The UI events ONLOAD, ONCHANGE and ONSUBMIT can invoke execution of <Math> structures by associating one or more Math structure IDs to the event.
-
The ONLOAD event is fired when the UI loads the page for initial presentation.
-
GLOBAL math, if defined, is executed without an explicit ONLOAD configuration noting the caveats described below.
-
-
The ONCHANGE event is fired after the user modifies the value of the associated field.
-
The ONSUBMIT event is fired when the user clicks a button to persist data.
-
Field data are not be persisted if the ONSUBMIT event generates errors.
-
-
-
There are two values for the <Math> element's GLOBAL attribute that designates the accessibility of math variables in the event's actions and across other math sections:
-
GLOBAL="Yes"
-
A rule can contain multiple global <Math> structures whose GLOBAL attribute value is "Yes", however, only the first structure defined in the rule is actually global and acts as a global <Math> structure.
-
As a best practice, only a single <Math> structure should be Global.
-
The first <Math> structure with the attribute value of "Yes" will process during the UI's ONLOAD event with no reference in the <Event> and will process before the configured non-global Math structures that are configured in <Event>s.
-
Math variables in Global Math are available during the lifetime of the UI and can be referenced in the Math and Actions of any of the three UI events.
-
A Global <Math> structure can be re-processed in ONCHANGE and ONSUBMIT events where the individual math variable values may change due to modifications in the field data.
-
-
Re-processing a global <Math> structure requires putting the structure's ID into the ONCHANGE or ONSUBMIT event's processing path through <Event> configuration.
-
-
-
GLOBAL="No"
-
There can be any number of non-global Math structures in a screen rule or transaction.
-
The <Math> structure processes only when its ID is configured into an Event's processing path through <Event> configuration.
-
Math variables are available during the lifetime of the event that invokes it and are not retained after the event.
-
Element/Tab | Parent Element | Attribute | Definition |
---|---|---|---|
<ScreenMath> |
Optional: The element is a structure that contains one or more Math sections that are performed from an <Event> and supply information to the Event's <Actions>. |
||
<Math> |
<ScreenMath> |
|
Required, Repeatable: This defines a section of Math identified by its ID. |
<Math> |
ID |
Required: This is the Math section's identification. Values:
|
|
<Math> |
GLOBAL |
Required: The attribute identifies the Math section and its variables as global, available for the life of the UI, or local, available only during the processing of an <Event>. Values:
|
|
<MathVariables> |
<Math> |
|
Required: This defines the structure holding one or more MathVariable statements representing a series of calculations, conditions and assignments implicitly or explicitly performed by <Event>s. |
<MathVariable>,<MathIf>,<MathLoop>, <MathStatement> |
<MathVariables> |
Required, Repeatable: One or more statements representing the calculations, conditions and assignments performed by a in the <Math> section. See the description of "Math capabilities available to ScreenMath" and the individual pages providing definition of these capabilities. |
Note: Most capabilities from the Transaction's Math element are available in ScreenMath. Below is a list of the Transaction's Math capabilities that are adopted by screen math. Information for each of these is accessible on their own pages.
AGGREGATEFUNCTION | COLLECTION | COLLECTIONVALUE | COMMUTATION | COMMUTATIONARRAY | CURRENCY | DATEARRAY |
EXITLOOP | EXPRESSION | FIELD | FUNCTION | FUNCTIONCALL | IDENTIFIER | IIF |
INTEGERARRAY | LOOPINDEX | MathIf | MathLoop | MathStatement - MathValuation only | MULTIFIELD | NUMERICARRAY |
OBJECT | OBJECTFIELD | OBJECTLOOP | PLANFIELD | POLICYFIELD | RATE | RATEARRAY |
SEGMENTFIELD | SEGMENTLOOP | SQL | STRINGARRAY | SUSPENSEFIELD | SYSTEMDATE | TEXTARRAY |
VALUATIONVALUE | VALUE |
XML Schema
<ScreenMath>
<Math ID="[name]" GLOBAL="[No | Yes]">
<MathVariables>
<MathVariable>...</MathVariable>
<MathVariable>...</MathVariable>
<MathIF>...</MathIF>
<MathIF>...</MathIF>
<MathLoop>...</MathLoop>
<MathLoop>...</MathLoop>
<MathStatement>...</MathStatement>
<MathStatement>...</MathStatement>
...
</MathVariables>
</Math>
<Math>...</Math>
</ScreenMath>
XML Example
<ScreenMath>
<Math ID="GlobalScreenMath" GLOBAL="Yes">
<MathVariables>
<MathVariable VARIABLENAME="TestMV" TYPE="VALUE" DATATYPE="TEXT">00</MathVariable>
<MathVariable VARIABLENAME="True" TYPE="VALUE" DATATYPE="INTEGER">1</MathVariable>
<MathVariable VARIABLENAME="False" TYPE="VALUE" DATATYPE="INTEGER">0</MathVariable>
</MathVariables>
</Math>
<Math ID="OnSubmitMath" GLOBAL="No">
<MathVariables>
<MathVariable VARIABLENAME="FederalAmountCurrencyCode" TYPE="FUNCTION" DATATYPE="TEXT">GetCurrencyCode(FederalAmount)</MathVariable>
<MathVariable VARIABLENAME="StateAmountCurrencyCode" TYPE="FUNCTION" DATATYPE="TEXT">GetCurrencyCode(StateAmount)</MathVariable>
<MathVariable VARIABLENAME="ZeroCurrencyFederalAmount" TYPE="FUNCTION" DATATYPE="CURRENCY">ToCurrency(0, FederalAmountCurrencyCode)</MathVariable>
<MathVariable VARIABLENAME="ZeroCurrencyStateAmount" TYPE="FUNCTION" DATATYPE="CURRENCY">ToCurrency(0, StateAmountCurrencyCode)</MathVariable>
</MathVariables>
</Math>
<Math ID="TimeCheckScreenMath" GLOBAL="No">
<MathVariables>
<MathVariable VARIABLENAME="PreCutoffTime" TYPE="VALUE" DATATYPE="TEXT">00</MathVariable>
<MathVariable VARIABLENAME="PostCutoffTime" TYPE="VALUE" DATATYPE="TEXT">01</MathVariable>
<MathVariable VARIABLENAME="SystemCutoffTimeGMT" TYPE="SQL" DATATYPE="INTEGER">SELECT CutOffTimeCriteria.IntValue FROM AsMapGroup JOIN AsMapValue ON AsMapValue.MapGroupGUID = AsMapGroup.MapGroupGUID JOIN AsMapCriteria CutOffTimeCriteria ON CutOffTimeCriteria.MapValueGUID = AsMapValue.MapValueGUID AND CutOffTimeCriteria.MapCriteriaName = 'MinutesAfterMidnightCutOffTime' WHERE AsMapGroup.MapGroupDescription = 'CutOffTimeGMT'</MathVariable>
<MathVariable VARIABLENAME="CurrentTimeGMT" TYPE="SQL" DATATYPE="INTEGER">SELECT to_char(cast((systimestamp AT TIME ZONE 'UTC') AS date),'HH24') * 60 + to_char(cast((systimestamp AT TIME ZONE 'UTC') AS date),'MI') FROM DUAL</MathVariable>
<MathVariable VARIABLENAME="RulesDevBank" TYPE="VALUE" DATATYPE="TEXT">Development Bank</MathVariable>
<!--Fetching the MasterSuspenseGUID and batch number as part of sample config-->
<MathVariable VARIABLENAME="IsSubSuspense" TYPE="VALUE" DATATYPE="TEXT">True</MathVariable>
<MathIF IF="IsEmpty(MasterSuspenseGUID)">
<MathVariable VARIABLENAME="IsSubSuspense" TYPE="VALUE" DATATYPE="TEXT">False</MathVariable>
</MathIF>
<MathVariable VARIABLENAME="NewBatchNumberSMV" TYPE="VALUE" DATATYPE="TEXT">Blank</MathVariable>
<MathVariable VARIABLENAME="MasterSuspenseBatchNumberSMV" TYPE="EXPRESSION" DATATYPE="TEXT">BatchNumber</MathVariable>
<MathIF IF="IsEmpty(MasterSuspenseBatchNumberSMV) And IsSubSuspense='True'">
<MathVariable VARIABLENAME="NewBatchNumberSMV" TYPE="IDENTIFIER" DATATYPE="TEXT">
<Parts>
<Part TYPE="VALUE">BN</Part>
<Part TYPE="SEQUENCE" FORMAT="0000000000">SuspenseBatchNumber</Part>
</Parts>
</MathVariable>
</MathIF>
<MathVariable VARIABLENAME="SubSuspenseBatchNumberSMV" TYPE="IIF" EXPRESSION="IsEmpty(MasterSuspenseBatchNumberSMV)" DATATYPE="TEXT">NewBatchNumberSMV, MasterSuspenseBatchNumberSMV</MathVariable>
</MathVariables>
</Math>
<Math ID="ExchangeRateMath" GLOBAL="No">
<MathVariables>
<MathVariable VARIABLENAME="ExchangRateCount" TYPE="SQL" DATATYPE="INTEGER">SELECT COUNT(*) FROM AsExchangeRate WHERE MarketMakerGUID = '[MarketMaker]' AND EffectiveDate = '[EffectiveDate]'</MathVariable>
</MathVariables>
</Math>
</ScreenMath>