【发布时间】:2018-04-04 23:56:14
【问题描述】:
我正在尝试在文件夹中创建新的项目表,但是我找不到确保该表是项目表的方法。
到目前为止,这是我的代码:
def create_resource_sheet(name):
""" Create a new resource sheet.
:param name:
:return:
"""
folder_id = get_resource_folder_id()
# TODO: Find and delete existing sheet with this name
resource_sheet = SS.models.Sheet({
'name': name,
# 'gantt_enabled': True, # This was added as an attempt to force it to a project sheet, but error 1032
'columns': [{
'title': 'Task',
'type': 'TEXT_NUMBER',
'primary': True,
'width': 200
}, {
'title': 'Status',
'type': 'PICKLIST',
'options': ['wtg', 'hld', 'ip', 'rdy', 'rev', 'fin', 'omt'], # TODO: Update this list
'width': 180
}, {
'title': '% Complete',
'type': 'TEXT_NUMBER',
'tag': ['GANTT_PERCENT_COMPLETE'],
'width': 85
}, {
'title': 'Assigned To',
'type': 'CONTACT_LIST',
'tag': ['GANTT_ASSIGNED_RESOURCE', 'GANTT_DISPLAY_LABEL'],
'width': 150
}, {
'title': '% Use',
'type': 'TEXT_NUMBER',
'tag': ['GANTT_ALLOCATION'],
'width': 60
}, {
'title': 'Days',
'type': 'DURATION',
'tag': ['GANTT_DURATION'],
'width': 70
}, {
'title': 'Start',
'type': 'ABSTRACT_DATETIME',
'tag': ['CALENDAR_START_DATE', 'GANTT_START_DATE'],
'width': 80
}, {
'title': 'Start',
'type': 'ABSTRACT_DATETIME',
'tag': ['CALENDAR_START_DATE', 'GANTT_START_DATE'],
'width': 80
}, {
'title': 'Finish',
'type': 'ABSTRACT_DATETIME',
'tag': ['CALENDAR_END_DATE', 'GANTT_END_DATE'],
'width': 80
}, {
'title': 'Type',
'type': 'TEXT_NUMBER',
'width': 150
}, {
'title': 'Comments',
'type': 'TEXT_NUMBER',
'width': 700
}
]
})
response = SS.Folders.create_sheet_in_folder(folder_id, resource_sheet)
new_sheet = response.result
return new_sheet
我收到以下错误代码:
smartsheet.exceptions.ApiError: {"result": {"shouldRetry": false, “代码”:1142,“名称”:“ApiError”,“错误代码”:1142,“推荐”: "未修复问题请勿重试。", "message": "列类型 DURATION 为项目工作表保留,不能手动设置 一列。”,“refId”:“6gurrzzwhepe”,“statusCode”:400}}
有没有一种方法可以从头开始创建项目表?
我尝试将 gantt_enabled 设置为 true,但这只是触发了另一个错误,设置 'project_settings' 也是如此。
我尝试仅使用主列创建工作表,然后使用 update_sheet 设置项目设置,这告诉我:To set projectSettings, you must first enable dependencies on the sheet.
我已尝试直接在 create_sheet 和 update_sheet 中设置依赖项,但都返回:The attribute(s) sheet.dependenciesEnabled are not allowed for this operation.
我会继续尝试,但我的想法越来越少。
【问题讨论】: