2017-01-24 45 views
2

我需要一个SharePoint工作流程,当文件上载到单独文档库(帐户文档)中的特定文件夹时,该工作流程将更新列表(帐户跟踪器)项目。文件夹的名称将与列表中要更新的行相对应。SharePoint工作流程根据单独文档库中的文件夹名称更新列表

所以,作为一个例子:

  1. 用户上传文件内“实体1”文件夹“帐户文件”库。
  2. 工作流程在'Accounts Tracker'中更新了一个标题为'Entity 1'的行,它自动基于'Accounts Documents'库中的文件夹名称。

的问题是如何在工作流中的库更新列表中的正确路线引用文件夹的名字吗?

回答

1

因此,如果我理解正确,目标是获取父文件夹名称,其中添加了文档,然后使用该名称更新具有该名称作为标题的列表项目。

工作流程中最复杂的部分是获取父文件夹名称。

包含该文档的文件夹的名称是变量的一部分当前项目:服务器相对URL

您可以在工作流程中使用一系列活动从服务器相对URL中提取文件夹名称。

Stage: Find Folder Name 
    Step: Set variables 
     Set Variable: FilePAth to Current Item:Server Relative URL 
     then Set Variable: TrimmedFilePath to Variable: FilePath 
     then Set Variable: index to 0 
     then Set Variable: LastIndexOf to -1 
     then Set Variable: PreviousLastIndexOf to -1 
    Loop: until last slash is found 
     The content of this loop will run repeatedly while Variable: index is greater than or equal to 0 
      Find/in Variable: TrimmedFilePath (Output to Variable: index) 
      If Variable: index is greater than or equal to 0 
       If Variable: LastIndexOf not Equals -1 
        Set Variable: PreviousLastIndexOf to Variable: LastIndexOf 
       then Calculate Variable: LastIndexOf plus 1 (Output to Variable: LastIndexOf) 
       then Calculate Variable: LastIndexOf plus Variable: index (Output to Variable: LastIndexOf) 
       then Calculate Variable: LastIndexOf plus 1 (Output to Variable: IndexPlus1) 
       then Copy from Variable: FilePath, starting at Variable: IndexPlus1 (Output to Variable: TrimmedFilePath) 
    Step: Check foldername 
     Calculate Variable: PreviousLastIndexOf plus 1 (Output to Variable:PreviousLastIndexOfPlus1) 
     then Calculate Variable: LastIndexOf minus PreviousLastIndexOfPlus1 (Output to Variable:FolderNameLength) 
     then Copy from Variable: FilePath, starting at Variable: PreviousLastIndexOfPlus1 for Variable: FolderNameLength characters (Output to Variable: ParentFolderName) 
     If (Variable: ParentFolderName equals Workflow Context:List Name) 
      Set Variable: ParentFolderName to Root Folder 

后,您需要一个更新列表项活动添加到您的工作流程。

查找列表项目部分,使用ParentFolderName变量检索目标列表元素。

希望得到这个帮助!

---解答一些问题

环的1号线是唯一的解释? 是的。在工作流程中添加循环时,您还可以添加评论。所以«直到发现最后一个斜杠»只是一条评论

循环的第二行 - 我该如何“查找变量”? 在工作流程中,您有一个活动来查找字符串变量中的字符。这与JavaScript中的indexOf类似。在这个工作流程中,我们需要找到一个斜杠«/»字符。请记住,目标是在URL中获取父文件夹。我们可以通过查找网址中的最后一个斜杠来找到它。

第9行Loop - 有多少个字符? 0是我工作流程中的默认设置。 字符的数量将自动计算。查找名为IndexPlus1的变量

Check的第4行 - 我没有工作流环境中的“列表名称” - 我可以使用“关联名称”吗? 我不知道你无法获取列表名称的原因。也许你可以尝试创建另一个SP 2013工作流程并查看是否遇到同样的问题?

第5行检查 - 是“根文件夹”硬格式化,即不是查找? 是的。根文件夹是硬编码的。

+0

嗨Sylvain。感谢您的详细回复 - 我很感谢您所付出的努力。不幸的是,当工作流程运行时出现错误。我可以请检查几件事吗? – sturleydog

+0

感谢您的详细回复,我很欣赏这种努力 - 不幸的是,当工作流程运行时,我收到了一个错误。 我可以检查几件事吗? - 循环的第一行仅供说明? - 循环的第二行 - 如何“查找/在变量中”? - 第9行Loop - 有多少个字符? 0是我工作流程中的默认设置。 - 第四行Check - 我没有工作流环境中的“List Name” - 我可以使用“Association Name”吗? - 第五行Check - 是“根文件夹”硬格式化,即不是查找? – sturleydog

+0

我在我的帖子中添加了一些对您问题的解答。 –

相关问题