6. Secondary Key

Prerequisites

Step 0: Task

I calculate cost differently for every customer. I want to look up the proper cost, based on secondaryKey of a line item. On algorithmical level, I need to know the following:

  • Name of the column with secondaryKey in the data.

Step 1: Prepare Lookup Configuration

To implement the above information, we will fill key2Field with the name of the PX column where matching value is stored. In our example, it is SecondaryKeyColumn:

image-20240603-144815.png

Fields:

  • key2Field – Column name or attributeId. Value of that column needs to match key2 of the current context. In PLI and PGI, key2 is always secondaryKey. Take into consideration that while still batched, the constructed filter needs to contain Filter.and of 200 filters instead of one Filter.in with 200 elements. This is an expected trade-off when using secondaryKeys.

Step 2: Call Lookup Library

Calling lookup library has not changed from the previous cookbook.

Step 3: Read Results

Reading results has not changed since the previous cookbook.