I am trying to pull “PracticeID” from the response array (see below) where PracticeCode = “FOVF”
I know I can use [1] to get the second object in the array like the script below, BUT our test systems don’t always have FOVF in the second array object.
Thanks!
Current script:
var authorizedPractices = JSON.parse(responseBody);
postman.setEnvironmentVariable(“PracticeID”, authorizedPractices.UserPracticeList[1].PracticeID);
My Response:
{
"ErrorCode": "",
"ErrorMessage": "",
"UserPracticeList": [
{
"PracticeID": 132528,
"PracticeCode": "BNUM",
"PracticeName": "Flagler Health"
},
{
"PracticeID": 16,
"PracticeCode": "FOVF",
"PracticeName": "Simpson, Moore and Moore"
},
{
"PracticeID": 7,
"PracticeCode": "OFC",
"PracticeName": "Eastside Urgent Care"
},
{
"PracticeID": 13,
"PracticeCode": "QVSR",
"PracticeName": "Paine and Associates"
},
{
"PracticeID": 19,
"PracticeCode": "YULE",
"PracticeName": "Southside Pediatrics"
}
]
}