0

I have trouble inserting values to a "picklist" column using smartsheet API and python. The value I am trying to insert is one of the options from the picklist as can be seen in the picture attached. I have no idea how to insert values to cells in the picklist column and I cant find any documentation for it

Code:

new_row = smartsheet.models.Row()
new_row.id = row_id
new_cell = smartsheet.models.Cell() #Cell configuration
new_cell.column_id = 5727843499960196
new_cell.value = "Jysk Bumpers"
new_cell.strict = False
new_row.cells.append(new_cell) 
updated_row = smartsheet_client.Sheets.update_rows(1398305516218244, # sheet_id
                                                   [new_row])
print("Complete")

Output:

{"response": {"statusCode": 400, "reason": "Bad Request", "content": {"detail": {"index": 0, "rowId": 8212749243377540}, "errorCode": 1235, "message": "Value is not supported for this column type. Use objectValue instead.", "refId": "wv6as6"}}}
Complete

Smartsheet picklist options

I tried using objectValue but still was not able to succeed.

1 Answers1

0

The following code sample updates 3 cells within an existing row:

  • the first cell is a Text/Number column type
  • the second cell is a Dropdown list column type that allows multiple values per cell
  • the third cell is a Dropdown list column type that allows only a single value per cell
# Define cell object (for the value in the first (primary) column - a text column) 
cell1 = smartsheet_client.models.Cell({
    'column_id': 3838793372985220,
    'object_value': 'new item'
})

# Define cell object (for the value in the second column - a multi-select dropdown) 
cell2 = smartsheet_client.models.Cell({
    'column_id': 3749273671624580,
    'object_value': smartsheet_client.models.MultiPicklistObjectValue({'values': ['blue', 'green', 'yellow']})
})

# Define cell object (for the value in the third column - a single-select dropdown) 
cell3 = smartsheet_client.models.Cell({
    'column_id': 8295973295810436,
    'object_value': 'cat 2'
})

# Create row that contains the 3 cells defined previously
row = smartsheet_client.models.Row({
    'id': 1724835021973380,
    'cells': [cell1, cell2, cell3]
})

# Update row
sheetId = 1303196942526340
result = smartsheet_client.Sheets.update_rows(sheetId, [row])

Based on the screenshot you included, it looks like the cell that you're trying to populate is in a Dropdown list column that allows multiple values per cell -- so you'll use the approach shown above for cell2 to set the value for that cell in your sheet. Please note that in the code sample above, I'm specifying 3 values for the multiple-select dropdown list in cell2:

smartsheet_client.models.MultiPicklistObjectValue({'values': ['blue', 'green', 'yellow']})

...but you can just specify one value (Jysk Bumpers) if that's the only item you want to be selected for that cell.

smartsheet_client.models.MultiPicklistObjectValue({'values': ['Jysk Bumpers']})
Kim Brandl
  • 13,125
  • 2
  • 16
  • 21