如何使用 smartsheet-csharp-sdk 将自动化工作流从 Smartsheet 模板传递到创建的 Smartsheets?

How to pass Automated Workflows from a Smartsheet Template to created Smartsheets using smartsheet-csharp-sdk?

因此,当从具有自动化工作流程的模板创建新的 Smartsheet 时,必须为 Smartsheet 选择一些选项才能继承该自动化。

(Example in Smartsheet)

Smartsheet API 内置了包含参数(Rules 和 RuleRecipients),可以将其传递到请求中以提供与我们在上面的表单中看到的相同的功能。

智能表中可用的包含参数API

参数包括(可选)——要从模板复制的以逗号分隔的元素列表或 sheet:

我们用来创建 API 调用的 smartsheet-csharp-sdk(v2.126.0) 已经包含在包含 类 中,带有预设参数。不幸的是,这些 Inclusion 类 不包含 Rules 和 RuleRecipients 参数。

SDK 中的包含参数(相关参数)

// Summary:
//     Represents specific elements that can be copied from a Template or Sheet into
//     a new Sheet.
public enum TemplateInclusion
{
    //
    // Summary:
    //     Includes the data.
    DATA = 0,
    //
    // Summary:
    //     Includes the attachments.
    ATTACHMENTS = 1,
    //
    // Summary:
    //     Includes the discussions.
    DISCUSSIONS = 2,
    //
    // Summary:
    //     Includes the cell links.
    CELL_LINKS = 3,
    //
    // Summary:
    //     Includes the forms.
    FORMS = 4
}

// Summary:
//     Represents specific elements to include in a response.
public enum SheetLevelInclusion
{
    //
    // Summary:
    //     Includes sheet-level and row-level attachments.
    ATTACHMENTS = 0,
    //
    // Summary:
    //     Includes columnType attribute in the row’s cells indicating the type of the column
    //     the cell resides in.
    COLUMN_TYPE = 1,
    //
    // Summary:
    //     contact references
    CONTACT_REFERENCES = 2,
    //
    // Summary:
    //     cross sheet references
    CROSS_SHEET_REFERENCES = 3,
    //
    // Summary:
    //     Includes sheet-level and row-level discussions.
    DISCUSSIONS = 4,
    //
    // Summary:
    //     Includes column filters and row.filteredOut attribute.
    FILTERS = 5,
    //
    // Summary:
    //     Includes column filter definitions
    FILTER_DEFINITIONS = 6,
    //
    // Summary:
    //     Includes column, row, and cell formatting.
    FORMAT = 7,
    //
    // Summary:
    //     object representation of cell value
    OBJECT_VALUE = 8,
    //
    // Summary:
    //     Includes the owner’s email address and user Id for each sheet.
    OWNER_INFO = 9,
    //
    // Summary:
    //     Includes a permalink attribute for each row. A row permalink represents a direct
    //     link to the row in the Smartsheet application.
    ROW_PERMALINK = 10,
    //
    // Summary:
    //     (DEPRECATED: use WRITER_INFO) Includes createdBy and modifiedBy attributes on
    //     the row, indicating the row’s creator and last modifier.
    ROW_WRITER_INFO = 11,
    //
    // Summary:
    //     Includes the source object indicating which sheet or template the sheet was created
    //     from, if any.
    SOURCE = 12,
    //
    // Summary:
    //     Includes SheetSummary object.
    SUMMARY = 13,
    //
    // Summary:
    //     Includes createdBy and modifiedBy attributes on the row or summary fields, indicating
    //     the row or summary field's creator, and last modifier.
    WRITER_INFO = 14
}

我们从 SDK 使用的 CreateSheetFromTemplate 方法确实有一个“includes”参数,但它只接受预构建 TemplateInclusion 的 IEnumerable。

Sheet CreateSheetFromTemplate(long workspaceId, Sheet sheet, IEnumerable<TemplateInclusion> includes);

我不确定如何绕过此问题以使用 SDK 的方式添加 Rules 和 RuleRecipients 参数。是否可以创建一个 Smartsheet 来使用 SDK 从模板继承自动化工作流程?或者我应该完全绕过它并创建一个传统的 API 调用?

我检查了包的源代码 (https://github.com/smartsheet-platform/smartsheet-csharp-sdk),TemplateInclusion 从未包含一次规则或 ruleRecipients。 我尝试使用 rest api 强制调用并且支持规则,但我怀疑 rulesRecipients 是...

url : https://api.smartsheet.com/2.0/sheets?include=rules,rulesrecipients,recipients
body : {"name":"newsheetFromTemplate", "fromId": 9999999999}

总而言之,我建议:

  • 创建功能增强请求
  • 在 github
  • 上报告问题
  • 不使用模板,而是sheet复制(支持规则)