Add new_row including values for a multi-select dropdown via Python SDK

12/03/20
Accepted

I've tried different thing but I still get the same error.

When I try the following code:

multival = smart.models.MultiPicklistObjectValue()

multival.values = value

new_cell.strict = True

new_cell.object_value = multival

new_row.cells.append(new_cell)

The column submission looks like:

"{"columnId": 7199257397618564, "objectValue": {"objectType": "MULTI_PICKLIST", "values": ["one", "two"]}, "strict": true}"

The error:

"{"response": {"statusCode": 400, "reason": "Bad Request", "content": {"errorCode": 5536, "message": "The value \"c[email protected]1b73a08\" could not be saved in column \"Audience\". This column is restricted to PICKLIST values only.", "refId": "l5hc94o7bn4e"}}}"

When I try:

new_cell.strict = True

new_cell.value = np.asarray(value)

new_row.cells.append(new_cell)

I get:

{"response": {"statusCode": 400, "reason": "Bad Request", "content": {"detail": {"index": 0}, "errorCode": 1012, "message": "Required object attribute(s) are missing from your request: cell.value.", "refId": "11w2h928lwr0c"}}}



Has anyone solved for this? How do you submit a new_row via Python when a column value is a multi picklist?

Best Answer

  • Accepted Answer

    I was able to add a new row doing the following:


    newrow = smartsheet.models.Row()

    newrow.cells.append({'column_id': xxxxxxx, 'object_value': {'objectType': 'MULTI_PICKLIST', 'values': ['One', 'Two']}, 'strict': True})

    smart.Sheets.add_rows(sheetid, newrow)


    This seems quite similar to what you did as well. Notably, when I was playing around and trying to break it, I was receiving errors that say "restricted to MULTI_PICKLIST values only" whereas what you posted above says "PICKLIST values only". Are you sure the column is a MULTI_PICKLIST column? If so, has it been a while since you updated the SDK? I remember it took a little bit before they updated it to support MULTI_PICKLIST columns after initial release of the feature.


    Not sure if any of the above will be helpful, but thought I'd do my best :)

Answers

  • Tim WellsTim Wells Employee

    Hi Brent,

    Can you do a quick check to verify that the column is in fact multi-select (from the UI it would be "Dropdown (Multi Select)..."? I can verify your error message/sample but only when I have selected "Dropdown (Single Select)..." with the "Restrict to dropdown values only" checkbox set.

    Thanks, Tim

  • Accepted Answer

    I was able to add a new row doing the following:


    newrow = smartsheet.models.Row()

    newrow.cells.append({'column_id': xxxxxxx, 'object_value': {'objectType': 'MULTI_PICKLIST', 'values': ['One', 'Two']}, 'strict': True})

    smart.Sheets.add_rows(sheetid, newrow)


    This seems quite similar to what you did as well. Notably, when I was playing around and trying to break it, I was receiving errors that say "restricted to MULTI_PICKLIST values only" whereas what you posted above says "PICKLIST values only". Are you sure the column is a MULTI_PICKLIST column? If so, has it been a while since you updated the SDK? I remember it took a little bit before they updated it to support MULTI_PICKLIST columns after initial release of the feature.


    Not sure if any of the above will be helpful, but thought I'd do my best :)

Sign In or Register to comment.