locked
List ID lookup based on criteria on multiple fields in workflow RRS feed

  • Question

  • Hi all,

    I am trying to update item in a list using workflow,but my problem is that i want to update the item based on two conditions where for example the items issue_status field is open and issue_openedby field is xyz.  Problem is I can't seem to do this as i can only do lookup on one field.  And I am not able to create a concatenated field in this list becaz both the fields are lookups and sharepoint doesnot let me create concatenated field when lookups are involved.  and in any case there are instances where i want to match using an or statement as well, that either item.field1 = something or item.field2 = something .  How can i do this in sharepoint ootbx

    Friday, November 11, 2011 7:57 PM

Answers

  • Hi,

     

    How did you define your workflow? You are creating workflow with SharePoint Designer or Visual Studio?

     

    I'm not sure if I understand you correctly. But I can update list items based on two lookup columns in the same list.

     

    Here are the steps I created my workflow:

     

    a)         I create two lookup fields in list A.

     

    b)         I ran SharePoint Designer to create a new workflow and attach this workflow to list A. Then make this workflow start when item is changed or created.

     

    c)         In conditions section, I created two compare list field actions and defined two workflow lookup to get the value from the two column I just created. Then set two value for them to compare.

     

    d)         In Actions section, I use the Update list item activity.

     

    Now if I create or change an item to meet the conditions I defined in conditions section, it will update the item automatically.

     

    And if you want an item will be updated if it meet either of two conditions, you can set the logic relationship of the two conditions to or instead of and.

     

    Hope this helps.

     

    Thanks,

    Pengyu Zhao

    • Marked as answer by Pengyu Zhao Thursday, November 17, 2011 11:35 AM
    Tuesday, November 15, 2011 9:28 AM
  • As per Pengyu Zhao

    You can change "and" to "or"

    • Edited by D-Virdi Tuesday, November 15, 2011 4:25 PM
    • Marked as answer by Confused001 Tuesday, November 15, 2011 7:19 PM
    Tuesday, November 15, 2011 4:24 PM

All replies

  • Hi,

     

    How did you define your workflow? You are creating workflow with SharePoint Designer or Visual Studio?

     

    I'm not sure if I understand you correctly. But I can update list items based on two lookup columns in the same list.

     

    Here are the steps I created my workflow:

     

    a)         I create two lookup fields in list A.

     

    b)         I ran SharePoint Designer to create a new workflow and attach this workflow to list A. Then make this workflow start when item is changed or created.

     

    c)         In conditions section, I created two compare list field actions and defined two workflow lookup to get the value from the two column I just created. Then set two value for them to compare.

     

    d)         In Actions section, I use the Update list item activity.

     

    Now if I create or change an item to meet the conditions I defined in conditions section, it will update the item automatically.

     

    And if you want an item will be updated if it meet either of two conditions, you can set the logic relationship of the two conditions to or instead of and.

     

    Hope this helps.

     

    Thanks,

    Pengyu Zhao

    • Marked as answer by Pengyu Zhao Thursday, November 17, 2011 11:35 AM
    Tuesday, November 15, 2011 9:28 AM
  • Thanks for your help, I need some more clarification though on step "C".  Can you show this visually? I am using SPD 2010 and I cant see how you are doing two workflow lookups as i dont see this options and also you are showing steps to do an "AND" statement how can i do an "OR" statement as well. Thanks
    Tuesday, November 15, 2011 1:58 PM
  • If you can't get Pengyu's algorithm to work, then here's what I do.

    In the lookup list, create a calculated field to contenate the two comparison fields.  Add something unique between them, like a dash or dot. (ex. =[field1] & "." * [field2]

    In the SPD WF, create a variable to mash together the two fields in the current item.  Then, use the mash to compare against the list and return the desired ListID.

    (This is the same method I use in Excel when trying to compare multiple columns using a SumIF or CountIF.)


    Steve Clark, MCTS | Twin-Soft.com
    Tuesday, November 15, 2011 2:59 PM
  • Thank SClark,  the concatenation doesnot work very well either, reason being the two fields are lookups of another list.  SP doesnot allow to concatenate lookup fields.  Now granated I can do this through workflow to write a concatenated field but i think this will only address "AND" type statements and not "OR" type statements.

    I am really interested how workflow will do an "AND" "OR" type statement with atleast two columns, i dont see this in the condition statements in SPD2010, essentially step C as mentioned above.  Please show visually, thanks

    Tuesday, November 15, 2011 3:32 PM
  • I'm only into 2007, so you'll need to get over to the 2010 forums to get a solid answer.  (The moderater will probably move this, now that he knows this.)


    Steve Clark, MCTS | Twin-Soft.com
    Tuesday, November 15, 2011 3:37 PM
  • oh i I didn't see there was little pre before the sharepoint 2010 in the forum name.

    In any case i think you prob understand the conundrum here with concatenation on fields that are of the type lookup.  Thanks for your help

    Tuesday, November 15, 2011 3:47 PM
  • I do, but I don't know enough about the new SPD to definitively say, "You can't do that." (Which I think is the right answer.)  But, I don't want to give anymore bad answers than I already do.

    Also, sorry I didn't realize that you were trying to Lookup to a Lookup.  That will require doing a couple more steps, but I think you could still pull it off.  Your WF will just have to be extra-hacky.


    Steve Clark, MCTS | Twin-Soft.com
    Tuesday, November 15, 2011 3:58 PM
  • i apperciate that.  I am really hoping Pengyu Zhao can come back and illustrate through images how he is doing step C.  I think this will even help with "OR" type lookups
    Tuesday, November 15, 2011 4:01 PM
  • As per Pengyu Zhao

    You can change "and" to "or"

    • Edited by D-Virdi Tuesday, November 15, 2011 4:25 PM
    • Marked as answer by Confused001 Tuesday, November 15, 2011 7:19 PM
    Tuesday, November 15, 2011 4:24 PM
  • haha, awesome! I cant believe it, this is exactly what i am looking for, I don't think this is there in SPD 2010.  I wonder if I can edit my sharepoint site using an older version of SPD. does any one know or how do i move this thread to 2010 and find out how to do this in 2010.  Thanks
    Tuesday, November 15, 2011 4:29 PM
  • Sorry.  I completely misread and overcomplicated this.


    Steve Clark, MCTS | Twin-Soft.com
    Tuesday, November 15, 2011 6:37 PM
  • Though still, please can someone show me how to do this exactly in SPD 2010
    Tuesday, November 15, 2011 7:09 PM
  • I can't believe that it is not same in SPD 2010, but you can post your question @ http://social.msdn.microsoft.com/Forums/en/sharepoint2010customization/threads .

    And "Mark as Answer" the thread which gave you the answer.


    Dare to promise
    Tuesday, November 15, 2011 7:18 PM