cancel
Showing results for 
Search instead for 
Did you mean: 

Search in structure list

jreategui
Not applicable

My recipe has the input parameter "Request Type". And we made a call to a JIRA API that returns this list:

 

 

{
    "requestTypeFields": [
        {
            "fieldId": "customfield_10072",
            "name": "Mobile Device Request Type",
            "description": "",
            "required": false,
            "defaultValues": [],
            "validValues": [
                {
                    "value": "10044",
                    "label": "New Order",
                    "children": []
                },
                {
                    "value": "10045",
                    "label": "Upgrade",
                    "children": []
                },
                {
                    "value": "10121",
                    "label": "Device Replacement",
                    "children": []
                }
            ],
            "jiraSchema": {
                "type": "option",
                "custom": "com.atlassian.jira.plugin.system.customfieldtypes:select",
                "customId": 10072
            },
            "visible": true
        },
        {
            "fieldId": "customfield_10077",
            "name": "Device Storage",
            "description": "",
            "required": false,
            "defaultValues": [],
            "validValues": [
                {
                    "value": "10061",
                    "label": "64 GB",
                    "children": []
                },
                {
                    "value": "10062",
                    "label": "128 GB",
                    "children": []
                },
                {
                    "value": "10063",
                    "label": "256 GB",
                    "children": []
                },
                {
                    "value": "10064",
                    "label": "512 GB",
                    "children": []
                }
            ],
            "jiraSchema": {
                "type": "option",
                "custom": "com.atlassian.jira.plugin.system.customfieldtypes:select",
                "customId": 10077
            },
            "visible": true
        }
    ]
}

 

 

My requirement is to return the Value "value" among all the options ("validValues") of the field whose "name" is "Mobile Device Request Type" and whose "label" is equal to the input parameter "Request type".

I found this way to do it:

img1.png

 

But with the "where" is try to find an exact match. That mean "New Order" <> "new order".

Is there a way to do something like:

 

img2.png

Thnaks in advance

 

 

 

 

1 REPLY 1

gary1
Executive Chef III
Executive Chef III

I find "where" very restrictive, and in most cases when I have to parse a complex array I use a Ruby action and different methods like filter, find, type, etc. 

My suggestions:

  1. You could upcase the entire API response in a JSON parser, and then upcase your request type
  2. You could input the API response into a Ruby action and parse it with different methods andmore flexibility