5. Data Validation and Currency
Prerequisites
You already went through the previous cookbook 4. ValidFrom and ValidTo.
Your CustomCost table already has a column with currency.
Step 0: Task
Currency is strictly connected to money value. I want to look it up together with any cost entry. I want specific behavior when the entry is missing data. On algorithmical level, I need to know the following:
Name of the column with currency.
What should happen if data is missing.
Step 1: Prepare Lookup Configuration
To implement the above information, we will modify two fields of our LookupConfiguration entry:
We will change the selectedFields entry to also look up the currency:
{"cost":"CostColumn"}
->{"cost":"CostColumn", "currency":"CurrencyColumn"}
We will add 2 more entries to our checksConfig Map.
Possible keys for the checksConfig Map are dynamically generated for each looked up column. In this case, we will configure automatically performed checks:
NO_FIRST_VALUE-cost
NO_FIRST_VALUE-currency
We will set up our lookup in a way that an exception is thrown when the cost is missing. However, our flow will assume that the currency might be missing. While it will produce a warning, it will not interrupt the flow.
Our checks config will change:
Before:
{"LOOKUP":"PSP_THROW","MORE_THAN_1":"PSP_WARNING"}
After:
{"LOOKUP":"PSP_THROW","MORE_THAN_1":"PSP_WARNING","NO_FIRST_VALUE-cost":"PSP_THROW","NO_FIRST_VALUE-currency":"PSP_WARNING"}
Fields:
checksConfig – Below checks are available in Configurable Lookups:
LOOKUP
← Advisable to at least throw in that caseMORE_THAN_1
NO_ENTRY
NO_FIRST_VALUE-${selectedField}
NO_ANY_VALUE-${selectedField}
This type of behavior is available for each of these checks:
IGNORE
LOG
PSP_WARNING
WARNING
PSP_THROW
THROW
PSP_ABORT
ABORT
Step 2: Call Lookup Library
Calling lookup library has not changed from the previous cookbook.
Step 3: Read Results
Your return map has changed in this cookbook, now it will contain 2 entries:
BigDecimal customCost = lookupResult?.cost
def customCurrency = lookupResult?.currency // customCurrency is nullable