2. Add PSP Dependency Level Fallbacks
Prerequisites
You understand how the three values in PSP DependencyMapping work.
You already went through the previous cookbook 1. Most Basic Scenario.
Step 0: Task
I want to look up Cost from a table using PSP Dependency Mapping. On algorithmical level, I need to know the following:
How to match data to proper dependency level.
Step 1: Prepare Lookup Configuration
This information is configured outside of Configurable Lookups, we will only specify that we are using this feature:
Fields:
IsUsingDependencyLevelHierarchy – Dependency level hierarchy will be passed through the Groovy code to Configurable Lookup Library.
Step 2: Call Lookup Library
You need to prepare two more values before calling the lookup library.
Entry from DependencyConfiguration PP. In PSP you can get it by calling:
Map dependencyLevelLookup = out.DependencyLevelLookup
Map with the same format as stored in DependencyMappingConfig (Dependency Mapping). We will refer to this map as "customCostDependencyMapping". Sample:
Map customCostDependencyMapping = [mappingType: "Lookup", dependencyLevelFilterField: "DependencyLevelName", sourceFilterField: "DependencyLevelNameColumn"]
mappingType –
Lookup
/Table
/None
sourceFilterField – Name of the column in dependencyConfiguration.
dependencyLevelFilterField – Name of the column in the data.
Look up the whole batch at once:
libs.ConfigurableLookupsLib.LookupInstanceFromPP.prepareConfiguredLookup("CustomCost",
"customCost", // This is element name, used for debugging
[thisDependencyInfo: dependencyLevelLookup, dependencyMappingConfig: customCostDependencyMapping]
)
Step 3: Read Results
Reading results has not changed since the previous cookbook.