cancel
Showing results for 
Search instead for 
Did you mean: 

Lookup Values in Snaplogic

Sravanthi_Kodak
New Contributor II

Hi,

I have a requirement in Snaplogic, from source I am getting country codes and in target i need to get complete country name. One way i can achieve this is by using database but client doesnot have any database Access which can be used.

Example:
Source value – UK
Target value need to be retrieved – United Kingdom.

I all other Integration tools this can be achieved using lookup values. But in Snaplogic we are stuck with the solution. Any Suggestions greatly helps us.

Thanks

2 REPLIES 2

christwr
Contributor III

tstack
Former Employee

If you can get the country code to name mapping into a JSON file, you can import that file into the pipeline as an expression library. Then, in a Mapper snap you can access the library to do the lookup.

So, first you would put the country mappings in a file called countryCodes.expr in SLFS. That file would contain a JSON object where the keys were the codes and the values were the name. It would look something like the following:

{
    "CL": "Chile",
    "CM": "Cameroon",
    "CN": "China"
}

You can then use the following expression in the Mapper snap to do the lookup:

lib.countryCodes[$country_code]

In that expression, the lib variable is used to access expression libraries and countryCodes is the name of the library file to access. The [$country_code] part is used to lookup the code, like “CN”, in the object to get the country name.