SharePoint Workflow Design: Copy List Item if list item does not exist on another list


Userlevel 2
Badge +9

Scenario:


We need a certain list item from List A to be copied to another list in a separate subsite's List B. In this workflow we need to test and see if List Item A exists on our List B before we decide to copy it over. If List Item A does not exist on List B then we will go through and do a Copy List Item Event to add List Item A to List B.


 


Design:
Please note that this is the barebones runthrough of what is required for achieving this behavior. There are many ways to get this design and your requirements will change based on the structure of your workflow and actual end goal of this process.


 


The "pseudocode" for this workflow would be as follows:


-Add SharePoint Workflow Integration wizard. Configure to use our desired list and then a desired start condition


-Get our SharePoint item from List A (Can be done via an item reference)


-Check if the item exists in List B via a Get List method on the SharePoint List B Smartobject. Input property should be the Unique ID from our List Item A


 


-Path 1 Line Rule (List A ID = List B ID):
If found do nothing, item already exists

-Path 2 Line Rule (List A ID <> List B ID):
If not found then copy item to List B from List A utilizing the SharePoint List Item Wizard (Copy List Items)


 


16602i002E88E9F71899C5.png


 


The main component here that gives us this behavior is the comparison we are doing via Line rules. This is the main logic that will determine what the workflow should do. To set a line rule in K2 Desginer for Visual Studio or K2 Studio we can right click on the line and select properties. The second wizard will give us the configuration for a line rule. We can then click add to configure it. Line rules tell the workflow where to go based off if the line rule is true. 


 


14508i6C4D9BB07F8BCDF9.png


 


Here is additional Documentation to discuss the various parts of K2 that are being used here:


 


Data Fields:


http://help.k2.com/onlinehelp/K2blackpearl/UserGuide/current/webframe.html#Data_Fields.html


http://help.k2.com/onlinehelp/K2blackpearl/UserGuide/current/webframe.html#Reference-ProcessActivityDataBrowser_DataFields.html


 


Copy List Item:


http://help.k2.com/onlinehelp/K2blackpearl/UserGuide/current/webframe.html#LIW13.html


 


Line Rules:


http://help.k2.com/onlinehelp/K2blackpearl/UserGuide/current/webframe.html#RTM_Reference_-_Adding_a_Line_Rule.html


0 replies

Be the first to reply!

Reply