cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to read the value from an array using expression builder and return true or false

snowamigo
New Contributor

My initial JSON looked like below

    "customFields": {
    "textCustomFields": [
      {
        "fieldId": "10546710413",
        "name": "templateUsageRestriction",
        "show": "false",
        "required": "false",
        "value": "allOptions"
      },
      {
        "fieldId": "10546710414",
        "name": "_source",
        "show": "true",
        "required": "false",
        "value": "ERM"
      },
      {
        "fieldId": "10546710415",
        "name": "_destination",
        "show": "true",
        "required": "false",
        "value": "xxx,yyy"
      },
      {
        "fieldId": "10546710416",
        "name": "_bu",
        "show": "true",
        "required": "false",
        "value": "ABC"
      },
      {
        "fieldId": "10546710417",
        "name": "_uid",
        "show": "true",
        "required": "false",
        "value": "pqr"
      },
      {
        "fieldId": "10546710418",
        "name": "_accountnumber",
        "show": "true",
        "required": "false",
        "value": "xyz"
      }
    ],
    "listCustomFields": []
  }

So I used below expression to map name => value.
Screen Shot 2021-03-06 at 11.43.04 AM

Now I am trying to read the "_sourceโ€™ element value, Ideally i want to do something like $.dsConfigAttributes[โ€˜_sourceโ€™] == โ€˜ERMโ€™ return true else false to a target path
and
$.dsConfigAttributes[โ€˜_sourceโ€™] contains "ERMโ€™ return to true else false to a target path

Screen Shot 2021-03-06 at 11.36.55 AM

Any help is appreciated.

1 ACCEPTED SOLUTION

bojanvelevski
Valued Contributor

Hello @snowamigo,

If you use this expression below, you will get true/false on the target path, respectively where the value of name is โ€˜_sourceโ€™ and value of โ€˜valueโ€™ is โ€˜ERMโ€™.

.map(x=> x.name == โ€˜_sourceโ€™ && x.value == โ€˜ERMโ€™)

If that is what you were aiming at. If not, please send more details on the output.

Best regards,

Bojan Velevski

View solution in original post

1 REPLY 1

bojanvelevski
Valued Contributor

Hello @snowamigo,

If you use this expression below, you will get true/false on the target path, respectively where the value of name is โ€˜_sourceโ€™ and value of โ€˜valueโ€™ is โ€˜ERMโ€™.

.map(x=> x.name == โ€˜_sourceโ€™ && x.value == โ€˜ERMโ€™)

If that is what you were aiming at. If not, please send more details on the output.

Best regards,

Bojan Velevski