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

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 \"com.navigo.smartsheet.rest.helper.sheet.cell.model.MultiPicklist@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

  • david.carli-arnold
    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 Wells
    Tim 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

  • david.carli-arnold
    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 :)

  • Alex Argumedo
    Alex Argumedo ✭✭✭✭

    I'm trying to implement a multi_picklist with a list of elements, the following code works with one element but fail with a second one, so i know the structure is good, but the format of my list maybe wrong, or I'm missing something


    def listToString(s):

        str1 = ""

        for e in s:

            str1 += e

            print(str1)

            return str1

    new_cell_add = smart.models.Cell()

    new_row_add.cells.append({'column_id': ######, 'object_value': {'objectType': 'MULTI_PICKLIST', 'values': (list of values)}, 'strict': True})

    I'm getting the error:

    {"result": {"code": 5536, "errorCode": 5536, "message": "The value \"com.navigo.smartsheet.rest.helper.sheet.cell.model.MultiPicklist@24f40bb\" could not be saved in column 

    What is the required format of the values?

    How to build a list of values intended to be added as object value list ?

    please help