Differentiate dropdown multi select (without options defined) with regular text columns

前提是你 提交于 2019-12-25 01:55:30

问题


Is there any way to differentiate columns that are of type drop down multi select from regular text columns :

This is supposed to be a multi select drop down list without any option :

    "id": 5414087443146628,
    "version": 2,
    "index": 2,
    "title": "Column3",
    "type": "TEXT_NUMBER",
    "validation": false,
    "width": 150

Same question goes for multi contact list without contact options defined.


回答1:


If you think of multi-contact or multi-dropdown as new versions of the various GET requests, then its easier to return the correct values. For multi-dropdown, you use a combination of query parameters of "level=3" and "include=objectValue", then you'll see the column type change to MULTI_PICKLIST instead of TEXT. (The TEXT value is to maintain backwards compatibility.)

So, essentially, your request would look something like GET /sheets/{sheetId}?level=3&include=objectValue.




回答2:


To test the scenario you've described, I created the following sheet structure in Smartsheet, where the column names indicate the type of each column:

Then I used Postman to issue a Get Sheet request for that sheet:

GET https://api.smartsheet.com/2.0/sheets/5831916227192708

The columns portion of the API response looks like this:

{
    "id": 5831916227192708,
    ...
    "columns": [
        {
            "id": 1256050323154820,
            "version": 0,
            "index": 0,
            "title": "Description",
            "type": "TEXT_NUMBER",
            "primary": true,
            "validation": false,
            "width": 124
        },
        {
            "id": 5759649950525316,
            "version": 0,
            "index": 1,
            "title": "Type=Text/Number",
            "type": "TEXT_NUMBER",
            "validation": false,
            "width": 128
        },
        {
            "id": 1323283741206404,
            "version": 0,
            "index": 2,
            "title": "Type=Dropdown (single select)",
            "type": "PICKLIST",
            "validation": false,
            "width": 111
        },
        {
            "id": 7741495861110660,
            "version": 2,
            "index": 3,
            "title": "Type=Dropdown (multiple select)",
            "type": "TEXT_NUMBER",
            "validation": false,
            "width": 113
        },
        {
            "id": 3048711514285956,
            "version": 0,
            "index": 4,
            "title": "Type=Contact List (single select)",
            "type": "CONTACT_LIST",
            "validation": false,
            "width": 122
        },
        {
            "id": 3992195570132868,
            "version": 1,
            "index": 5,
            "title": "Type=Contact List (multiple select)",
            "type": "TEXT_NUMBER",
            "validation": false,
            "width": 125
        }
    ],
    ...
}

In this response, we see the following:

  • If column type is specified as Text/Number, the type attribute value is TEXT_NUMBER
  • If column type is specified as Dropdown (single select), the type attribute value is PICKLIST
  • If column type is specified as Dropdown (multiple select), the type attribute value is TEXT_NUMBER
  • If column type is specified as Contact List (single select), the type attribute value is CONTACT_LIST
  • If column type is specified as Contact List (multiple select), the type attribute value is TEXT_NUMBER

Therefore, it doesn't seem possible to programmatically differentiate a Dropdown (multiple select) column from a Text/Number column or a Contact List (multiple select) column from a Text/Number column, based on column metadata alone. IMO, seems like a bug for the Dropdown (multiple select) column type and Contact List (multiple select) column type to return type: TEXT_NUMBER. Perhaps someone with Smartsheet can comment here to provide more insight into this behavior.




回答3:


Did a few tests and level 3 isn't available : https://api.smartsheet.com/2.0/sheets/{sheetId}?level=3 :

{
  "errorCode": 1018,
  "message": "The value '3' was not valid for the parameter 'level'.",
  "refId": "1godowa5cigf1"
}

Although i tried with level 2 and got the info : https://api.smartsheet.com/2.0/sheets/{sheetId}?level=2&include=objectValue

Results for a multi drop down list :

{
        "id": 5414087443146628,
        "version": 2,
        "index": 2,
        "title": "Column3",
        "type": "MULTI_PICKLIST",
        "options": [
            "a",
            "b"
        ],
        "validation": false,
        "width": 150
    }


来源:https://stackoverflow.com/questions/58218904/differentiate-dropdown-multi-select-without-options-defined-with-regular-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!