cancel
Showing results for 
Search instead for 
Did you mean: 

Using Templates to drive Smartlink or JSON output

murphy-brian
New Contributor III

Has anyone figured out how to create Templates to drive the Target Schema in a mapper snap? This would be useful to standardize JSON output schema outputs and also reduce the time it takes to map outputs. If not can someone explain when and how a Target Schema actually shows something in a mapper?

5 REPLIES 5

nganapathiraju
Former Employee

SmartLink is only enabled when the mapper is the snap before a target snap (like a database, or rest or soap or whatever end point) and of course you have incoming document schema.

If there is anything between mapper and the target snap, then it may not work.

So why can’t I use a JSON generator input on the output side of a Mapper to force a schema? This way I can map and control the output without having to do all the manual mappings?

This also provide the ability to define reusable Schemas

JSON generator does not trigger introspection as we call it.

Here is something one of my colleague @asharifian shared with us.

In the past, when faced with mapping many fields, I either had to manually input the fields to the Mapper snap or strip out the Mapper JSON from the SLP file, copy to Excel, input the fields there, then paste back to the SLP. This process was tedious, time consuming, and prone to mistakes. Because of that, I created a CSV to Mapper pipeline. This is ideal for scenarios where you’re dealing with many fields and it’d take too long to manually input into the Mapper snap.
All you need is a CSV input file containing three columns: source, target, and expression (to indicate whether the field should have the expression toggle on or off). Sample CSV input file is attached. Once you’re done inputting your fields to the CSV (you can do this via Excel), upload it to the SLDB and execute the CSV_to_Mapper pipeline (attached).

Once the pipeline is finished executing, an SLP file is outputted (called OutputtedMapper.slp). Import this SLP file to the SnapLogic platform and you’ll see your outputted Mapper is there with all of the fields. You can now copy/paste that Mapper snap to your main pipeline.

Hope this helps. Feel free to modify the pipeline as you see fit for your use case.

Here are the sample csv and pipeline.

Please rename the test.csv.txt to test.csv

test.csv.txt (234 Bytes)
CSV_to_Mapper.slp (19.3 KB)

This is such an amazingly helpful tool! If you find yourself needing to create target definition across many fields, this save SO MUCH TIME!

Thank you Ali!!!