How to programmatically erase a date column cell, with project settings and dependencies enabled?

Hi everyone! Need your help! I'm currently facing a challenge while attempting to programmatically erase a date column cell, with project settings and dependencies enabled. I am able to change the date, but not able to erase the existing date. I can successfully delete the column value manually, but I'm not able to achieve the same using the Smartsheet SDK 2.105.1. Note: The column properties state, "This column type can't be changed due to the following: It's being used in schedule calculations. Edit project settings." Thank You!

Answers

  • Kleerfyre
    Kleerfyre ✭✭✭✭✭✭

    So what are you using the SDK to connect to? I don't have a lot of experience with the SDK, but some more context would most likely help anyone else that might be able to help.

    Jonathan Sanders, CSM

    "Change is always scary because it is unknown, but facing the unknown is what makes us stronger."

  • Devi
    Devi ✭✭

    pseudo code:

    new_row = smartsheet_client.models.Row()

    new_row.id = row_id

    new_cell = ss_client.models.Cell()

    new_cell.column_id = column_id

    new_cell.value = '' #Not deleting the existing cell value. The column project settings/dependencies enabled.

    #new_cell.value = today #Succesfully updated the cell value with today

    new_cell.strict = False

    new_row.cells.append(new_cell)

    smarthseet_client.Sheets.update_rows(sheet_id, [new_row])

  • Devi
    Devi ✭✭
    edited 06/08/23

    Let me rephrase my question. If the column has project settings and dependencies enabled, is it possible to programmatically erase the date cell directly through the Smartsheet API?


    Through API, I am able to update but not able to erase the existing date.


    code:


    new_row = smartsheet_client.models.Row()
    
    new_row.id = row_id
    
    new_cell = ss_client.models.Cell()
    
    new_cell.column_id = column_id
    
    new_cell.value = '' #Not erasing the existing cell value. The column project settings/dependencies are enabled.
    
    #new_cell.value = today #Succesfully updated the cell value with today. The Column project settings/dependencies are enabled.
    
    new_cell.strict = False
    
    new_row.cells.append(new_cell)
    
    smarthseet_client.Sheets.update_rows(sheet_id, [new_row])
    
  • jmyzk_cloudsmart_jp
    jmyzk_cloudsmart_jp ✭✭✭✭✭✭

    Hi @Devi

    You need to remove the "Predecessors" value first.

    Then, as new_cell.value=" or " " does not work to set a Date cell to blank, I set the value to something else like, "None."

    code:

        # Remove Predecessors

        new_cell = smartsheet.models.Cell()

        new_cell.column_id = column_map["Predecessors"] # a dictionary created before (map[title]=id)

        new_cell.value = ""

        new_cell.strict = False

        new_row.cells.append(new_cell)


        # Remove Start Date Value

        new_cell = smartsheet.models.Cell()

        new_cell.column_id = column_map['Start']

        new_cell.value = "None"  # "" or "  " does not work so "nothing" etc.

        new_cell.strict = False

        new_row.cells.append(new_cell)


  • Devi
    Devi ✭✭

    @jmyzk_cloudsmart_jp What is the reason behind the need to delete the value of the Predecessors first? Today, I was able to successfully erase the Start date column, even with dependencies enabled, without removing the value of the predecessors. It's unclear why this functionality didn't work in the past. Thank You!