AutoNumber systemColumnType via API

I am trying to add a AutoNumber column type to a sheet
It seems to work just fine

The issue I am having is the "autoNumberFormat" seems to be ignored.

I can go into the smartsheet.com and manually edit the prefix, and suffix, and starting number in the sheet and it works fine… but the API isn't applying this on column creation?

Any ideas why?

Side note: There used to be an autonumber column - but it was deleted prior. Seems this is where the new autonumber is starting at where the previous one left off with the same prefix and suffix.

Tags:

Answers

  • Here is an example I just tried again

    import smartsheet
    # Initialize Smartsheet client with your access tokenaccess_token = 'access token'smartsheet_client = smartsheet.Smartsheet(access_token)
    # Define the new auto-number columnnew_column = smartsheet.models.Column({    'title': 'AutoNumberTest',   # Column title    'type': 'TEXT_NUMBER',       # Column type    'systemColumnType': 'AUTO_NUMBER',  # Specify that this is an auto-number column    'index': 0,                  # The index where this column will be added    'autoNumberFormat': {        # Auto-number formatting details        'fill': '0000',          # Zero-padding for numbers (4 digits)        'prefix': 'TEST-',       # Optional prefix before the number        'startingNumber': 1,     # Starting number for the sequence        'suffix': '-END'         # Optional suffix after the number    },    'description': 'This is an auto-number column',  # Optional description    'width': 200  # Optional column width in pixels})
    # Add the new column to the specified sheetsheet_id = 9999999  # Replace with your actual sheet IDnew_columns = smartsheet_client.Sheets.add_columns(sheet_id, [new_column])
    # Print the resultsprint("New column added:", new_columns)

    Returned:
    New column added: {"data": [{"autoNumberFormat": {"fill": "0", "prefix": ", ", "suffix": ","}, "description": "This is an auto-number column", "id": 4895256532438916, "index": 0, "systemColumnType": "AUTO_NUMBER", "title": "AutoNumberTest", "type": "TEXT_NUMBER", "validation": false, "width": 200}], "message": "SUCCESS", "result": [{"autoNumberFormat": {"fill": "0", "prefix": ", ", "suffix": ","}, "description": "This is an auto-number column", "id": 4895256532438916, "index": 0, "systemColumnType": "AUTO_NUMBER", "title": "AutoNumberTest", "type": "TEXT_NUMBER", "validation": false, "width": 200}], "resultCode": 0, "version": 48}


    As you can see the autoNumberFormat returned is not what I passed in the payload above

  • SSFeatures
    SSFeatures ✭✭✭✭✭

    Hi @jarredcody,

    I noticed that in your first screenshot you set the column type using:

    systemColumnType: "AUTO_NUMBER"
    

    And in the second screenshot you set the column type using:

    type: "TEXT_NUMBER"
    systemColumnType: "AUTO_NUMBER"
    

    How about trying this instead:

    type: "AUTO_NUMBER"
    

    For example:

    new_column = smartsheet.models.Column({
        "title": "Auto Number",
        "type": "AUTO_NUMBER",
        "autoNumberFormat": {
            "prefix": "TEST-",
            "startingNumber": 1
        }
    })
    

    Let me know if this fixes the problem!

    SSFeatures - The browser extension that adds more features into SmartSheet.

    • Automatic sorting, sorting with filters, saving sort settings
    • Spell checking
    • Report PDF generator that supports grouped and summarized reports

  • @SSFeatures That did not work

    It has not problem creating the column - it is a "systemColumnType"
    it is not applying the autoNumberFormat

  • I ran as you suggested and received an error
    it wants the

    systemColumnType

    ({    "title": "Auto Number",    "type": "AUTO_NUMBER",    "autoNumberFormat": {        "prefix": "TEST-",        "startingNumber": 1    }})

    {"response": {"statusCode": 400, "reason": "Bad Request", "content": {"errorCode": 1012, "message": "Required object attribute(s) are missing from your request: {0}.", "refId": "c64a9418-416e-494f-b4bd-d71165c99b34"}}}
    New column added: {"result": {"code": 1012, "errorCode": 1012, "message": "Required object attribute(s) are missing from your request: {0}.", "name": "ApiError", "recommendation": "Do not retry without fixing the problem. ", "refId": "c64a9418-416e-494f-b4bd-d71165c99b34", "shouldRetry": false, "statusCode": 400}}