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

JavaScript Connector handling null values

jharrison
Deputy Chef II
Deputy Chef II

Has anyone had luck handling null values in a JavaScript Connector? I have tried all these below but the error remains "Cannot read properties of null (reading 'regulation')"

regulation = arrayValue.regulation
regulation = arrayValue.regulation || 0
regulation = arrayValue[0].regulation || 0
if(arrayValue.regulation === null){regulation = "null"} else {regulation = arrayValue.regulation}
if(arrayValue.regulation != null){regulation = arrayValue.regulation} else {regulation = "null"}

 

1 ACCEPTED SOLUTION

Found it! The JSON had spacing that was different than the sample file I was using. I realized that all these attempts at finding the correct path to the key were where I needed to focus. So I went back and looked more closely at the parse JSON Output and noticed the spaces in the Output that I had not placed in the sample document of JSON parse, which is why it kept resulting in 'undefined'. Added the spacing and it worked.

Thanks for your help

Jim

View solution in original post

12 REPLIES 12

gary1
Executive Chef II
Executive Chef II

Is this an accurate representation of input_json? Not sure if Status is an object or an array.

[{
"FirstName": "Spider",
"LastName": "Man",
"EmployeeId": "123",
"Status": {
"Regulation": null
}
}]

  

Yes, minus a couple square brackets [].

[{
"LastName": "",
"FirstName": "",
"Message": null,
"Status": [
{
"Regulation": ""
}
]
}]

maryhodges
Community Manager
Community Manager

Hey Jim, 

Here are a couple threads that might be helpful! 

Cheers,
Mary

Community Manager
Workato
https://www.linkedin.com/in/mary-yukari-hodges/