A. Introduction
When creating a workflow using Office SharePoint Designer, you might choose to start the workflow when a
new item is created OR
whenever an item is changed. Consider the case that the actions performed in both situations are the same except for one step which should differ based on whether the processed item is a new one or just an updated one.
A simple straight-forward solution is to create two workflows that differ only by one step. I don't need to elaborate on how inconvenient this approach is: (1) during the development phase (2) whenever you need to maintain the workflows.
As the title conveys, in this article I would like to show how one can use the Conditions section to determine whether the workflow was triggered due to an item's change or a new item's creation. This way, you would need only one workflow which would branch whenever needed and merge back.
B. Preparations
Create the list, which we would attach the workflow to. For this demo, I have created a custom list called
Price List.
C. Workflow
- Open
Microsoft Office SharePoint Designer 2007.
- Click
File >
Open Site.
- Enter the
URL of the site containing our custom list called Price List.
- Now click
File >
New >
Workflow.
- On the
Define your new workflow page, enter the following data:
- Name: CreateOrEdit
- Attachment List: Price List
- Start Options: Automatically start this workflow when a new item is created and Automatically start this workflow whenever an item is changed

- Click
Next, in order to start designing the workflow steps.
- Enter
Check whether the item is new or updated as the
Step Name.
- In the
Conditions section, select
Compare Price List field.
- Click the
field link and select
Created.
- Leave the
operator as
equals.
- Click the
value link then click
fx. For the
source select
Current Item and for the
field select
Modified.
- Click
OK.
- In the
Actions section, select the action
Log to History List.
- Click the
this message link and type the text:
This is a new item.
- Click the
Add 'Else If' Conditional Branch.
- In the
Else branch add the action
Log to History list.
- Click the
this message link and type the text:
This is an updated item.

- Click
Finish, in order to save and publish the workflow.
D. Test the solution
1. Create a new item.
-- Check that the CreateOrEdit workflow has completed successfully.
-- Check that the History Log displays the comment: This is a new item.
2. Edit the created item.
-- Check that the CreateOrEdit workflow has completed successfully.
-- Check that the History Log displays the comment: This is an updated item.
No comments:
Post a Comment