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.

  • ivicakoteski's avatar
    ivicakoteski
    New Contributor III

    Hi aakumar,
    The map() method is an iterative method and returns a new array with the values transformed by the given callback.
    The current expression constructs a new array containing an object, where the object's property value is assigned the value of "rd.sc".

    I have updated the expression to be more descriptive:
    $SRSAPI.filter(f=>f.agrDetails.riskLevel == "Low Risk").map(element=>{"rd":{"sc":element.rd.sc}})

    BR.
    Ivica