views:

2485

answers:

6

I am new to SharePoint but I learn quick.

I want to trigger a workflow only when a value is updated in a list item, but not everytime the item is changed. For example I have a column for approve/not approve and I want that to be the trigger not the other values in the item. So if anything else is changed the workflow will not start unless the 'approval' value is.

All help is appreciated!

Thanks,

+1  A: 

You can do that in SharePoint Designer.

  • Open you site in SharePoint Designer
  • Click File New WorkFlow
  • Choose your List/Library
  • Add a Condition: Compare ListName Field (you can compare values in the field in your case your approve column)

Hope it helps.

Ali_Abadani
Ali,Thanks, but this is something I already have set up. The problem is that after the value is updated, everytime the item is changed (other columns that the one that trigger the workflow) the workflow restars, and in my case re-sends an email (it was set up to Actions: send an email). Other suggestions?Thanks,
Marius
+1  A: 

Hi Marius

You probably need two workflows, a hidden field and a "Start another workflow activity" (which can be found on CodePlex)

Workflow 1 is a helper workflow which is set to start when an item is changed: It check if Status is equal to hidden field If it is the exit If not then start workflow 2 and set hidden field to current value of Status

Workflow 2 is then the real workflow which does what you want when Status is changed

Per Jakobsen
+1  A: 

If you wish to accomplish this programmatically...

  1. Create a ItemUpdating event handler and attach it to your target list. I would create a feature and feature receiver to do the attaching.

  2. In the ItemUpdating event handler, there are two values you want to look at: properties.ListItem["Approval"] this will give you the original value properties.AfterProperties["Approval"] this is the updated value

Check if the two values are not equal to each other, and if the updated value is equal to "approve". If both are true, start a workflow on the list item programmatically- here are some links to help you with that:

http://www.sharepointkings.com/2008/09/how-to-start-workflow-programmatically.html

http://www.tonytestasworld.com/post/Howto-Start-a-Sharepoint-Workflow-Programmatically.aspx

Happy coding!

Ajay Nayak
A: 
  1. First create a hidden numeric field called "Workflow Status" Set the default value to "0"

  2. Create a workflow that will initiate on both the creation of and item and on modify

  3. The first step in the workflow is to increase the field Workflow Status by "1"

  4. The second step is to verify is the value is 2 which should indicate the first time the workflow has been modified.

Just to indicate the status.

Workflow Status = 1: Item has been created 2: Item has been modified for the first time 3: Item has been modified a second time.

Martin
A: 

@Marius: The first step in the workflow should be to compare the field value and provide a logic branch. If the value equals what you want then run the worlflow. If not, stop the workflow or do something else. If the email is being received with any modification then you have got your flow wrong.

Martin's solution is very straightforward but you can also expand on this by using content types to allow for an approval process that performs another action.

PANoone