Showing results for 
Search instead for 
Did you mean: 

Escaping Single Quotes in Error Pipeline - Issue

New Contributor

Fairly new SL user here.

I am in the process of creating an error pipeline to handle system generated errors that may occur in our pipelines.

In this error pipeline we capture the error, error reason, error resolution, snap name, and the original record name/value pairs for all fields on the record that failed to load.

We capture this information from the error response JSON array passed from the failed parent pipeline to the error pipeline. See example:

        "error": "Cannot invoke toExponential() on a function",
        "stacktrace": "com.snaplogic.snap.api.SnapDataException: Cannot invoke toExponential() on a function\n\tat sl.EvaluatorUtils.methodInternal(\n\tat sl.EvaluatorUtils.method(\n\tat SC.evaluate(Unknown Source)\n\tat com.snaplogic.util.ExpressionUtils$MyExpressionProperty.eval(\n\tat com.snaplogic.snap.api.impl.PropertyValuesImpl$ValidatingExpressionProperty.eval(\n\tat com.snaplogic.snaps.transform.DataTransform.processBinary(\n\tat com.snaplogic.snaps.transform.DataTransform.process(\n\tat com.snaplogic.snap.api.ExecutionUtil.process(\n\tat com.snaplogic.snap.api.ExecutionUtil.executeForDocument(\n\tat com.snaplogic.snap.api.ExecutionUtil.execute(\n\tat com.snaplogic.snap.api.SimpleSnap.execute(\n\tat\n\tat\n\tat\n\tat\n\tat\n\tat java.base/ Source)\n\tat java.base/java.util.concurrent.Executors$ Source)\n\tat java.base/ Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$ Source)\n\tat java.base/ Source)\n",
        "reason": "Functions only have an apply() method",
        "resolution": "Please check expression syntax and data types.",
        "status_code": "error",
        "snap_details": {
            "label": "Mapper",
            "instance_id": "1abcdefg2-abc-123a-123b-123abc123abc",
            "class_id": "com-snaplogic-snaps-transform-datatransform",
            "build_tag": "snaps12345",
            "views": {
                "in": {
                    "input0": {
                        "count": 267
                "out": {
                    "output0": {
                        "count": 0
                "error": {
                    "error0": {
                        "count": 266
        "original": {
            "value": 1266,
            "field1": "123456",
            "field2": "NEW YORK",
            "field3": "NY",
            "field4": "12345",
            "field5": "16:00:01",
            "field6": "AUTOMATION TEST CLIENT",
            "field8": "123 SESAME ST",
            "field9": "",
            "field10": "",
            "field11": "12/02/2019 00:00:00",
            "field12": "12/03/0001 00:00:00",
            "field13": "",
            "field14": "0",
            "field15": "0",
            "field16": "",
            "field17": "",
            "field18": "",
            "field19": "M",
            "field20": "3",
            "field21": "SOMEUSR",
            "field22": "Elmo's Burgers"

Currently I am having an issue with escaping special characters - specifically single quotes (') that are received in the name value pairs for the original. See field 22 in the above example.

I have attempted the following to remove them using the replace function:


When replace or replaceAll is applied to the $reason and $resolution fields, the single quotation is escaped when we receive them, however when $original.replaceAll(“'”,“‘’”) is used single quotes are not escaped - same results when using JSON.stringify($original).replaceAll(“'”,“‘’”).

Any advice on how to escape these single quotes would be greatly appreciated.


Valued Contributor

Hi @jpsheff,

I suppose that you are trying to replace single quotes with double quotes.

I have built one simple pipeline containing the expression for replacing the single quotes in the original object.

SingleQuote_Issue_2020_03_31.slp (3.8 KB)

Please take a look on the attached pipeline, and let me know if this will resolve the issue.


New Contributor III

Hello @jpsheff
If you want to replace the single with double quotes, Spiro’s example is great.
But if you trying to replace single quote with empty space, you can use replace method with a regex like this Screenshot_2

Best Regards

New Contributor

@Spiro_Taleski and @dimche.saveski thank you both for your responses. Ultimately JSON.stringify($original).replace( /'/g,“‘’”) fit the bill, as my target was a JSON defined field on a table.