Forum Discussion

aakumar's avatar
aakumar
New Contributor III
2 years ago
Solved

array.map if field1 meets criteria, I want field2

IF   riskLevel=="Low Risk" then move rd.sc to new array.  How can I can accomplish this please?
  • ivicakoteski's avatar
    ivicakoteski
    2 years ago

    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

  • aakumar's avatar
    2 years ago

    Got it, appreciate you for taking the time to explain it to me. Thanks.