cancel
Showing results for 
Search instead for 
Did you mean: 

how to filter out spaces

aakumar
New Contributor III

How do I remove spaces from the output ?

Output of this pipeline is

 [  {
"lrs": [
"Indiana",
"Alabama",
""
] }
]

2 ACCEPTED SOLUTIONS

endor_force
New Contributor III

You have two approaches, one is to continue on the path with a mapper and javascript methods, but you can use the filter method before map to only include the low risk.

$suppliersRisksResponseFromSupplierSAPI
.filter(x => x.aggregateRiskDetails.riskLevel == "Low Risk")
.map(x => x.riskDetails.supplierLocationStateCode)


The second approach is to use standard snaps to achieve the result, it may look more busy in SL designer but it is adding better readability and flexibility for the future if you want to work with other data from the input.
Attached is a sample, it will output the name of each low risk state as a separate document which you can work with or group as you wish.

View solution in original post

endor_force
New Contributor III

Awesome!

Since the community does not allow upload of files with extension .slp, you can download the txt file and rename it from .txt to .slp and import it as a pipeline in snaplogic designer or manager.

View solution in original post

4 REPLIES 4

endor_force
New Contributor III

You have two approaches, one is to continue on the path with a mapper and javascript methods, but you can use the filter method before map to only include the low risk.

$suppliersRisksResponseFromSupplierSAPI
.filter(x => x.aggregateRiskDetails.riskLevel == "Low Risk")
.map(x => x.riskDetails.supplierLocationStateCode)


The second approach is to use standard snaps to achieve the result, it may look more busy in SL designer but it is adding better readability and flexibility for the future if you want to work with other data from the input.
Attached is a sample, it will output the name of each low risk state as a separate document which you can work with or group as you wish.

aakumar
New Contributor III

Your first solution of using filter & then Map works perfect. Thank you. 

I don't know how to use the text file you attached. Is that a Javascript file?

Anyways, I got my solution. I appreciate your help.

 

 

endor_force
New Contributor III

Awesome!

Since the community does not allow upload of files with extension .slp, you can download the txt file and rename it from .txt to .slp and import it as a pipeline in snaplogic designer or manager.

aakumar
New Contributor III

Renamed the file to .slp  and ran the demo. It works perfect.  Thank you.