我必须做什么才能通过复制工作区来复制工作表的工作流程?

发布于 2025-01-17 16:40:58 字数 1593 浏览 5 评论 0原文

为了自动化我的一些工作,我正在深入研究 javascript 和 smartsheet-api,... 我编写了一个脚本,通过使用新的工作空间名称复制整个工作空间来设置工作空间。与不同的人共享工作区,与其他人共享单独的工作表,在新生成的工作表之间生成一些链接,...

其中一些操作并不像我想象的那么容易,...尽管如此,最后它起作用的那天。

但现在我发现,工作表的工作流程没有被复制,...复制的工作表中没有工作流程。

我使用 Node 作为我的 javascript 运行时环境。

//-------------------------------------------------------------------------------------
                                                           // prepare copying  the workspace
                                                           // ------------------------------
    var body = { newName: workspaceName };                     // store the workspaceName from the function-parameters in the body-object 
    var params = { include: "all, rules, ruleRecipients", skipRemap: "" };    // set parameters 
    var options = { workspaceId: sourceWorkspaceID, body: body, queryParameters: params }; // create the options-object with all the settings above

    //--------------------------------------------------------------------------------------
    try {                                                              // Try copying workspace
        copiedWorkspace = await ss.workspaces.copyWorkspace(options);  // ---------------------
        console.log('setupTheWorkspace: Workspace wurde kopiert.');
    } catch (e) {
        console.log('setupTheWorkspace: Workspace konnte nicht kopiert werden.');                                  
        console.log(e);        

上面的代码显示了方法,我进行复制。首先,我尝试仅使用“all”作为包含参数,然后将“rules,ruleRecipients”添加到包含参数中,但无济于事。

我必须做什么才能通过复制工作区来复制工作表的工作流程?

To automate some work of mine, i'm diving into javascript and the smartsheet-api, ...
I wrote a script that sets up a workspace by copying the whole workspace with a new workspacename. Sharing the workspace to different people, share individual sheets to other people, generate some links to and from the newly generated sheets, ...

Some of these actions weren't as easy, as I thought, ... Nevertheless, at the end of the day it worked.

But now I found out, that the workflows of the sheets weren't copied, ... there are no workflows in the sheets copied.

I'm using node as my javascript-runtime-environment.

//-------------------------------------------------------------------------------------
                                                           // prepare copying  the workspace
                                                           // ------------------------------
    var body = { newName: workspaceName };                     // store the workspaceName from the function-parameters in the body-object 
    var params = { include: "all, rules, ruleRecipients", skipRemap: "" };    // set parameters 
    var options = { workspaceId: sourceWorkspaceID, body: body, queryParameters: params }; // create the options-object with all the settings above

    //--------------------------------------------------------------------------------------
    try {                                                              // Try copying workspace
        copiedWorkspace = await ss.workspaces.copyWorkspace(options);  // ---------------------
        console.log('setupTheWorkspace: Workspace wurde kopiert.');
    } catch (e) {
        console.log('setupTheWorkspace: Workspace konnte nicht kopiert werden.');                                  
        console.log(e);        

The code above shows the way, I do the copying. First I tried it with only "all" as the include-param, then I added "rules, ruleRecipients" to the include-param, but to no avail.

What do I have to do, that the worklows of the sheets are copied by copying the workspace?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

狠疯拽 2025-01-24 16:40:58

一些评论:

  • 复制工作区的 Smartsheet API 文档 操作将 include 参数的 all 值描述为 已弃用。通常建议避免使用标记为“已弃用”的任何内容。

  • include 参数的值不应包含任何空格。我怀疑这是您问题的根源 - 即 Smartsheet 无法识别包含前导空格的值 - 例如 'rules''ruleRecipients' -因此忽略它们。

  • 如果我正确理解文档,如果您想重新映射新创建的工作区中的某些引用,则只需指定 skipRemap 参数即可。指定该参数为空值是没有意义的——如果您不打算为其指定值,我建议您将其删除。

以下代码行反映了这些建议:

var params = { include: "rules,ruleRecipients" };

注意:如果您希望将其他内容(工作流程除外)复制到新工作区,请务必向 include 参数添加其他值。该文档包含所有有效值的列表。请确保逗号分隔的值列表中不包含任何空格。

下面是一些成功复制工作区的示例代码(并指定 include 参数的所有值)。

// Specify new workspace name
var body = {
  newName: 'My New Workspace'
};

// Set elements to copy
var params = {
  include: 'attachments,cellLinks,data,discussions,filters,forms,rules,ruleRecipients,shares'
};

// Set options
var options = {
  workspaceId: 6192537502279556,
  body: body,
  queryParameters: params
};

// Copy workspace
smartsheet.workspaces.copyWorkspace(options)
  .then(function(copiedWorkspace) {
    console.log(copiedWorkspace);
  })
  .catch(function(error) {
    console.log(error);
  });

A few comments:

  • The Smartsheet API docs for the Copy Workspace operation describe the all value of the include parameter as deprecated. It's generally recommended to avoid using anything that's marked as 'deprecated'.

  • The value of the include parameter should not contain any spaces. I suspect this is the source of your issue -- i.e., Smartsheet is not recognizing values that contain a leading space -- e.g., ' rules' or ' ruleRecipients' -- and therefore is ignoring them.

  • If I'm understanding the docs correctly, you only need to specify the skipRemap parameter if you want to NOT remap certain references in the newly created workspace. Specifying that parameter with an empty value doesn't make sense -- I'd suggest you remove it if you're not going to specify a value for it.

Here's the line from your code that reflects these recommendations:

var params = { include: "rules,ruleRecipients" };

Note: Be sure to add additional values to the include parameter if you want other stuff (besides workflows) to be copied to the new workspace. The docs contain a list of all valid values. And be sure to NOT include any spaces in the comma-delimited list of values.

Here's some sample code that successfully copies a workspace (and specifies all values of the include parameter).

// Specify new workspace name
var body = {
  newName: 'My New Workspace'
};

// Set elements to copy
var params = {
  include: 'attachments,cellLinks,data,discussions,filters,forms,rules,ruleRecipients,shares'
};

// Set options
var options = {
  workspaceId: 6192537502279556,
  body: body,
  queryParameters: params
};

// Copy workspace
smartsheet.workspaces.copyWorkspace(options)
  .then(function(copiedWorkspace) {
    console.log(copiedWorkspace);
  })
  .catch(function(error) {
    console.log(error);
  });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文