Skip to content

Instantly share code, notes, and snippets.

@jmyzk
Created June 9, 2023 09:27
Show Gist options
  • Save jmyzk/b6a10d66d85654deb1fd0205d798c300 to your computer and use it in GitHub Desktop.
Save jmyzk/b6a10d66d85654deb1fd0205d798c300 to your computer and use it in GitHub Desktop.
How to programmatically erase a date column cell, with project settings and dependencies enabled?
import smartsheet
def remove_start_date(sheet_id, row_number):
access_token = "" # your access token
smartsheet_client = smartsheet.Smartsheet(access_token)
sheet = smartsheet_client.Sheets.get_sheet(sheet_id)
# Create Column Map
column_map = {}
for column in sheet.columns:
column_map[column.title] = column.id
row_id = sheet.rows[row_number].id
column_id = column_map['Start']
# Build the row to update
new_row = smartsheet.models.Row()
new_row.id = row_id
# Remove Predecessors
new_cell = smartsheet.models.Cell()
new_cell.column_id = column_map["Predecessors"]
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)
# Update rows
updated_row = smartsheet_client.Sheets.update_rows(
sheet_id, # sheet_id
[new_row]
)
if __name__ == '__main__':
sheet_id = input('sheet_id')
row_number = int(input('row number'))
remove_start_date(sheet_id, row_number)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment