App Connect

 View Only

Performing a simple key / value lookup in IBM App Connect Designer

By Martin Ross posted Sat September 10, 2022 06:35 AM

  
Performing a lookup is a common task in integration for routing, enrichment and various other reasons. The characteristics of the lookup table can vary wildly depending on requirements and scenario, from a small number of static values to thousands of rows that need to be updated dynamically. With built-in capabilities and connectivity options available within the App Connect Designer and Toolkit authoring tools there are a number of options available to the user - from performing the lookup against data stored in external databases or caches, to defining the lookup table locally to remove the requirement on external systems and components. Here we will look at how to implement a simple. static lookup table within IBM App Connect Designer.


Performing a simple lookup using Set variable and Jsonata lookup function


Let's start by creating a simple Flow for API - from the dashboard click to create a new "Flow for API" and then give your flow and model a name, for this example we will use "lookup" for the the flow and model name, and then click to "Create model".


Next, define a single string property "prop1" then in the "operations" tab choose "Retrieve lookup by Id" and click to "Implement flow".


As well as the vast array of connectors available for you to build your integrations, IBM App Connect Designer also provides a toolbox with a set of utilities that you can use to apply specialized processing.


From the toolbox the Set variable utility allows you to define simple or complex variables, we will use this to define our lookup table of key / value pairs. Select "Set variable" to add to your flow and then define the lookup table.


Now that we have the lookup table defined, select the response node and for the response "prop1" field we will use the Jsonata lookup function to retrieve the value from the table based on the key being passed in to the flow.


We can now test the flow works as expected using the built-in testing capabilities. Select the "Request" node and then click to edit your sample data - enter "key3" as the sample data, this should result in "value3" being returned following the lookup.


​Now to test the flow, click on the "Try this flow" icon above the canvas and you should see a successful response with "value3" being returned in the response.


Following the above steps you should have now:
  • Created a Flow for API
  • Defined a lookup table using the Set variable toolbox capability
  • Configured the API response to be calculated by using the Jsonata lookup function to retrieve a value from the lookup table based on a given key
  • Successfully tested your flow using the built-in test capabilities
0 comments
186 views

Permalink