Forum Discussion

Arijit's avatar
Arijit
New Contributor
2 years ago

Error in the Snaplogic Mapper for excel Merged fields

I am trying to process a excel file using Excel parser and on the mapper we want to pull the previous not null value for a field if the value of the field is null for which have tried the below expressions but snaplogic is giving error .

option 1 :

$Value == null ? $Value.substring(0, $Value.length() - 1) : $Value

option 2 :

$Value == null ? $previous.Value : $Value

Error :

Failure: Expression worked for 1 previous document, but failed on document #2 with the error: $previous is undefined. Perhaps you meant: $B, $Label, $Value, Reason: 'previous' was not found while evaluating the sub-expression '$previous', Resolution: Check the spelling of the property or, if the property is optional, use the get() method (e.g. $.get('previous'))

The Excel file that I am trying to process has the rows as below :

1 Reply

  • bojanvelevski's avatar
    bojanvelevski
    Valued Contributor

    Hey @swatifunde,

    I presume you exposing this as an api?
    If that’s the case, than switch from document to binary output. Map
    $ as $content, 200 as $status "application/json" as $['content-type'].

    Hope this helps

    • swatifunde's avatar
      swatifunde
      Contributor

      yes, I am exposing this as an api. but I don’t understand solution here.
      If I use Document to binary snap then how can I map this values.

      • bojanvelevski's avatar
        bojanvelevski
        Valued Contributor

        You don’t have to use document to binary. What I meant was change the output of the mapper to binary. You can do that in in the Views tab on the Mapper: