Forum Discussion

Amrita's avatar
Amrita
New Contributor
5 years ago

Replace Values in a file from Mapping Sheet

Hi All,

I’m looking for an approach to generate a transformed file where column values will be replaced with Target values from a mapping sheet dynamically. So there will be two input files-1.Extract ,2.Mapping(sample below)

Extract:
BU VENDOR SITE
xx BU yy 101
pp BU yy 102

Mapping:

Expected output:
BU VENDOR SITE
US BU ABC Inc. 101
CA BU ABC Inc. 102

Any approach to achieve this dynamically will be very helpful. As the Columns names can change for Mapping & Extract files.

  • nickhumble - could you simply enable the "Null-safe access" option and always reference the values you're looking for?  If it doesn't exist, it will just be a null value.  This would bypass the need for the get() method, which as you have found out, can't be used under multiple levels of object nesting.

    • nickhumble's avatar
      nickhumble
      New Contributor II

      Thanks koryknick - this might just be the simplistic genius i was looking for!

  • If that doesn't work for you, then try this:

    $.get('/position/field_2354910', {}).get('value')

    Since the Object.get() method allows you to provide a default if the field doesn't exist, this example returns an empty object, so calling the next get() on the empty object will also return null.

    Hope this helps!

    • nickhumble's avatar
      nickhumble
      New Contributor II

      Thanks - my problem was i couldn't get a non-null value using .get, no matter what i tried. I wondered whether the forward slashes were confusing it or something, but .hasPath worked ok so i'm a bit stumped.

      Your earlier suggestion has worked well though - thank you.