I am pulling data via SmartSheet API and not all objects have the property “value” defined. I am struggling a bit with the required Javascript to add the “value” property when not present within an object.
With my current workflow, I am getting a "Cannot set properties of undefined (setting ‘value’) in the CODE node when it hits the first instance of an undefined “value” property
Here is input data to the Code2 Node:
{
“id”:275169835870084,
“rowNumber”:1,
“expanded”:true,
“createdAt”:“2022-11-28T08:49:32Z”,
“modifiedAt”:“2023-01-26T12:04:49Z”,
“cells”:[
{
“columnId”:2940315076192132,
“value”:“Danley Sound Labs”,
“displayValue”:“Danley Sound Labs”
},
{
“columnId”:7443914703562628
},
{
“columnId”:1814415169349508,
“value”:“July”,
“displayValue”:“July”
}
]
…
…
The expected output is as follows:
{
“id”:275169835870084,
“rowNumber”:1,
“expanded”:true,
“createdAt”:“2022-11-28T08:49:32Z”,
“modifiedAt”:“2023-01-26T12:04:49Z”,
“cells”:[
{
“columnId”:2940315076192132,
“value”:“Danley Sound Labs”,
“displayValue”:“Danley Sound Labs”
},
{
“columnId”:7443914703562628,
“value”: " "
},
{
“columnId”:1814415169349508,
“value”:“July”,
“displayValue”:“July”
}
]
Any help would be greatly appreciated!
Information on your n8n setup
- **n8n version: 0.210.1
- **Database you’re using (default: SQLite): SQLite
- **Running n8n with the execution process [own(default), main]:own
- **Running n8n via [Docker, npm, n8n.cloud, desktop app]:Docker