Welcome to the Smartsheet Forum Archives
The posts in this forum are no longer monitored for accuracy and their content may no longer be current. If there's a discussion here that interests you and you'd like to find (or create) a more current version, please Visit the Current Forums.
How to handle blank cells through the API
Hi Everyone,
I have a concern regarding the API. I am currently accessing the API through PHP (5.6) curl calls.
The concern I have is regarding the blank cells. I have tried validating the cells through their property [VALUE] as described by the documentation. However, I am unable to properly parse through blank cells. In PHP I have tried using property_exists() and isset() methods but they all fail to identify cells with blank [VALUE]
Is there a better way to check and validate if the retreived cell is blank or not?
Any input would be greatly appreciated.
Thank you
Comments
-
Hi Jerry,
There are actually two different types of blank cells. There are blank cells that have never had a value, or have no history. And there are cells that are currently blank, but have held a value sometime in the past.
Cells with no history don't exist according to the API.
Blank cells that have a history return a columnId and type, but no value or displayValue.
For example, say we have a row with three columns. The cells array for that row returned from the API would look something like this:
"cells": [
{
"columnId": 7903811353241476,
"type": "TEXT_NUMBER",
"value": "0011a000004ca5ZAAQ",
"displayValue": "0011a000004ca5ZAAQ"
},
{
"columnId": 585461958764420,
"type": "TEXT_NUMBER",
"value": "Global Media",
"displayValue": "Global Media"
},
{
"columnId": 2635295230322564,
"type": "TEXT_NUMBER",
"value": 4.0,
"displayValue": "4"
}
]
In the next row, the middle cell is currently blank, but has a history. The cells array for that row would look like:
"cells": [
{
"columnId": 7903811353241476,
"type": "TEXT_NUMBER",
"value": "0011a000004ca5YAAQ",
"displayValue": "0011a000004ca5YAAQ"
},
{
"columnId": 585461958764420,
"type": "TEXT_NUMBER"
},
{
"columnId": 2635295230322564,
"type": "TEXT_NUMBER",
"value": 3.0,
"displayValue": "3"
}
]
Then, in the last row, the third column has a blank cell with no history. So its cell array would look like:
"cells": [
{
"columnId": 7903811353241476,
"type": "TEXT_NUMBER",
"value": "0011a000004ca5XAAQ",
"displayValue": "0011a000004ca5XAAQ"
},
{
"columnId": 585461958764420,
"type": "TEXT_NUMBER",
"value": "Acme",
"displayValue": "Acme"
}
]
So, isset() would work in the situation where the blank cell had a history. However, you would need to take a different approach for the blank cells with no history.
To check for blank cells with no history, I would recommend looping over the columns in a row and checking if the cell for that column exists first, and then checking to see if the cell value isset().
-
Hi Scott,
Thanks for the advice. I will be sure to look into it.
Sincerely,
Jerry
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64.1K Get Help
- 414 Global Discussions
- 221 Industry Talk
- 460 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 141 Just for fun
- 58 Community Job Board
- 461 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 299 Events
- 38 Webinars
- 7.3K Forum Archives