Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have list in SharePoint with a field that I want to auto-populate based on values of other fields in the row. I would normally use a calculated field but the calculated field doesn't have everything I need to do that. Therefore, instead I would like to use a workflow on the list that is triggered when an item is created/changed and that will set the value of my calculated field. I've already done this by creating the workflow through the SharePoint UI but I would now like to do this using visual studio for ease of deployment.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

The event receiver is much better suited for your task. You need to create an event receiver and handle ItemAdding/ItemUpdating or ItemAdded/ItemUpdated events in synchronous mode. Workflow is more useful for long-running operations whti often some people interaction involved.

share|improve this answer
    
Thanks. That worked great for me and did not require much code. –  skeletank Feb 13 '12 at 21:16
add comment

I personally would recommend doing this in an event receiver instead of a workflow. Visual Studio 2010 has a nice project template you can use if you have SharePoint 2010 - otherwise look into a VS plugin tool called WSP Builder. This link can provide you some insight on how to create the event receiver.

share|improve this answer
add comment

I'm assuming this is for SharePoint 2010.

Using SharePoint Designer 2010 you can create workflows and then export them for ease of deployment. A workflow this simple will be easier in SPD vs Visual Studio.

If you want to do it in VS, you'll need VS2010, installed on a box with SharePoint installed. You can then create a SharePoint workflow project, then create some actions and using custom code you can modify the columns accordingly. There are a load of great tutorials to walk you through this process online.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.