locked
Workflow return ALL matching items, not just first RRS feed

  • Question

  • Hi all,

    I have two lists: One captures the big details of a project, other is for entering individual tasks for each one.  The individual tasks have a field where the project can be selected and it links it to the overall Project. Now, because each project can have multiple tasks attached, I need a workflow that can return the URL or Linked title of ALL matching tasks. Not just the first one...

    Does that make sense?

    Any help is greatly appreciated!

    • Changed type kb0722 Sunday, April 8, 2012 4:32 PM
    • Moved by star.warsModerator Sunday, April 22, 2012 9:38 AM SP 2007 question (From:SharePoint 2010 - General Questions and Answers)
    Sunday, April 8, 2012 4:31 PM

Answers

  • Hi Karen,

    I'm really sorry for that the above steps can't work, I find that the behavior to get the lookup type column value is different between SharePoint Design 2007 and SharePoint Designer 2010.

    SharePoint Desinger 2007 should get the value directly(e.g. get value "projectA" from lookup column "1;#projectA"), so the step 2.2 is not needed.

    Your actions should look like(This workflow is associated with your Task list "testing 2" in your case):

    Set Variable: TaskUrl to <a href=http://my sit/Sites/Divisions/mydivision/system/Lists/testing%202/DispForm.aspx?ID=[%testing 2:ID%]>[Testing 2:Title]</a>
    Then Update item in Project List
    The update list item looks like this:
    List: Project List
    Field to update: Tasks
    Value: Variable: TaskUrl
    Find the List item
    Field: Project List:Title
    Value: Variable: LookupProjectTitle which is a lookup column in "testing 2" list.

    Then the workflow should add all matched tasks url in project list.

    Since that the Project list column Tasks enabled "Append Changes to Existing Text" option, it will not directly display all tasks in list view in AllItem.aspx page, you can right-click list web part and "Convert to XSLT data view", then change the code line per this article,

    Replace the code (assume you use Tasks column in Project list. )

    <xsl:value-of disable-output-escaping="yes" select="@Tasks" />

    With

    <SharePoint:AppendOnlyHistory FieldName="Tasks" runat="server" ControlMode="Display" ItemId="{@ID}"/>

    The final Project list effect should be like,

    Thanks


    Daniel Yang

    TechNet Community Support



    Wednesday, April 18, 2012 3:30 AM
    Moderator

All replies

  • Hi kb0722,

    You can follow the steps below,

    1. Create an Multiple lines of text type rich text column (e.g named as Individual_Tasks) with "Append Changes to Existing Text" option enabled in Project list, which is used to store the individual tasks Title link from Task list.   And assume that you have used a Lookup type column in Task list to store the Project Title(e.g. named as Task_under_Project),  
    2. Then create a workflow associated with the Task list, construct the Task Title link in workflow variable and update it in Project list in workflow.
    • 2.1. Use Action "Set Workflow Variable" to set workflow variable TaskUrl to <a href =http://yourServer/youSite/Lists/Task/DispForm?ID=[%Current Item:ID%]>[%Current Item:Title%]</a>.
    • 2.2. Then you can extract the the project title from lookup type column Task_under_Project column (e.g. value is like format 1;#projectA and 2;#projectB etc ) using action "Extract Substring from Index of String", starting at 4, Output  to valuable: substring1.
    • 2.3. Then update Project list column Individual_Tasks with value of TaskUrl, set Find list item field condition: Project list Title is equal to substring1, like image below.

                                 Update List Item

    Thanks


    Daniel Yang

    TechNet Community Support

    Tuesday, April 10, 2012 8:57 AM
    Moderator
  • Hi Daniel!

    Thanks very much for the answer.  I'm afraid I've posted in the wrong forum.  I wish we had SharePoint 2010.  Would this technique work with the "Build Dynamic String" action available in SharePoint 2007?

    Again, thanks for your help.  I've been beating my head against my desk trying to figure this out,

    Karen

    Tuesday, April 10, 2012 9:52 PM
  • So, I just went ahead and played with the Dynamic String Builder Option. I've gotten to the point where the worfklow is returning a hyper linked value... it just happens that the value is: [%Current Item:Title%]

    What super obvious thing am I missing?

    Karen

    Tuesday, April 10, 2012 10:23 PM
  • Hi Karen,

    The "Dynamic String Builder" can also be used to construct the hyperlink of the Task item Title mentioned in step 2.1, you can input like below in Dynamic String Builder, 

    <a href =http://yourServer/youSite/Lists/Task/DispForm?ID=[%Current Item:ID%]>[%Current Item:Title%]</a>

    For step 2.2, SharePoint Designer 2007 does not have the action like "Extract Substring from Index of String",  I find a third-party custom action "Substring(start)" with the similar function you can try.

    http://paulgalvinsoldblog.wordpress.com/2007/11/18/new-release-sharepoint-designer-workflow-extensions-string-manipulation-functions/

    Thanks


    Daniel Yang

    TechNet Community Support


    Wednesday, April 11, 2012 11:55 AM
    Moderator
  • Hi Daniel,

    I was unable to get that third party extension to work.  I've found another one that works similarily: http://www.nickgrattan.net/Downloads/Custom%20Workflow%20Activity%20Pack.pdf

    I'm still having trouble... I'm using the Mid String function mentioned in that PDF.

    Here is what my actions look like:

    Set Variable: TaskUrl to <a href=http://my sit/Sites/Divisions/mydivision/system/Lists/testing%202/DispForm.aspx?ID=[%testing 2:ID%]>[Testing 2:Title]</a>

    Then Mid String from testing 2:Title start at 4 length 50 Output to Variable: StringMid2

    Then Update item in Project List

    The update list item looks like this:

    List: Project List

    Field to update: Tasks

    Value: Variable: TaskUrl

    Find the List item

    Field: Project List:Title

    Value: Variable:StringMid2

    I'm so very in over my head....  Any thoughts?

    Set Variable: TaskUrl to

    Tuesday, April 17, 2012 10:29 PM
  • Hi Karen,

    I'm really sorry for that the above steps can't work, I find that the behavior to get the lookup type column value is different between SharePoint Design 2007 and SharePoint Designer 2010.

    SharePoint Desinger 2007 should get the value directly(e.g. get value "projectA" from lookup column "1;#projectA"), so the step 2.2 is not needed.

    Your actions should look like(This workflow is associated with your Task list "testing 2" in your case):

    Set Variable: TaskUrl to <a href=http://my sit/Sites/Divisions/mydivision/system/Lists/testing%202/DispForm.aspx?ID=[%testing 2:ID%]>[Testing 2:Title]</a>
    Then Update item in Project List
    The update list item looks like this:
    List: Project List
    Field to update: Tasks
    Value: Variable: TaskUrl
    Find the List item
    Field: Project List:Title
    Value: Variable: LookupProjectTitle which is a lookup column in "testing 2" list.

    Then the workflow should add all matched tasks url in project list.

    Since that the Project list column Tasks enabled "Append Changes to Existing Text" option, it will not directly display all tasks in list view in AllItem.aspx page, you can right-click list web part and "Convert to XSLT data view", then change the code line per this article,

    Replace the code (assume you use Tasks column in Project list. )

    <xsl:value-of disable-output-escaping="yes" select="@Tasks" />

    With

    <SharePoint:AppendOnlyHistory FieldName="Tasks" runat="server" ControlMode="Display" ItemId="{@ID}"/>

    The final Project list effect should be like,

    Thanks


    Daniel Yang

    TechNet Community Support



    Wednesday, April 18, 2012 3:30 AM
    Moderator
  • Not in 2007 or 2010 can this be properly done. You may read here and there about looping workflows that call themselves but ignore this advice, it will not work, even when people say it will. You can DISPLAY items like Daniel does, but you cannot run workflows on them.

    Please mark my response as an answer if appropriate.
    Learn.SharePoint.com

    • Proposed as answer by Learn.SharePoint.com Wednesday, April 18, 2012 4:02 AM
    • Unproposed as answer by kb0722 Wednesday, April 18, 2012 4:07 AM
    Wednesday, April 18, 2012 4:02 AM