Reputation: 617
I have 2 lists: List A and List B.
My goal is to copy over an item in List A to List B.
In SharePoint Designer 2007, here are the available Workflow commands:
- Create List Item
- Update List Item
- Copy List Item
Which command creates a list item in List B "if it does not exist", and updates the list item in List B "if it exists"?
Upvotes: 2
Views: 14175
Reputation: 125
I had this same question yesterday at work. Here is how I solved it today.
Lists: Parent: List A Target: List B
Create the workflow and associate it with the Parent List. The workflow can start however you please.
You will need 3 Steps in your workflow.
Step 1: Create a workflow variable and use a lookup to set the variable to the Title (this can be any unique field) of the Target list. I chose the Title field because I knew it would be unique to each item. No conditions required. Action: Set Variable:Foo to Bar (where Bar is the field you chose to match against)
Step 2: Check if the variable you just assigned equals the title (or unique field of your choice) of the item you just created/edited in the Parent list. So your condition will be: If Variable:Foo equals Bar (where Bar is the field you chose) and your Action will be: Stop the workflow
Step 3: If we make it to step 3, then our variable did not match an existing item No conditions are required in this step. Action: Copy Item then stop the workflow.
That's it!
Additionally, if you'd like to loop through your lists and process everything, this article was very helpful for me: SharePoint Looping Workflow - How to: Loop through and process all items in a list
I hope this makes sense. And I hope it works for you as well as it has for me!
Upvotes: 3
Reputation: 186
Your workflow will need to check list B first. If the item exists then it will need to "Update List Item". If it does not exists, it will need to "Copy List Item".
So how can you check?
There's a great article on doing that here: http://blog-sharepoint.blogspot.com/2009/08/spd-workflow-test-if-value-exists-in.html
Upvotes: 1