Friday, March 4, 2011

How do you extract a value from a field of the associated item in a custom Sharepoint workflow?

I'm creating a custom WSS workflow in Visual Studio 2008 and have a 'create task' activity. When creating the task I want to be able to reference some of the field values from the list item that is associated with the workflow and for the life of me I can't seem to determine how to get at the values within the fields on that item. I know that you can use:

workflowProperties.Item

to access the item itself, but if I want to retrieve the value of a field on that item that's called 'Amount Requested' how would I go about doing that? I've seen the 'GetFromattedValue(string)' method, but I don't really want the formatted value, a raw string value is really all I want.

From stackoverflow
  • Hello,

    workflowProperties.Item is just an SPListItem, meaning you can access it using SPListItem["named_column"]:

    SPListItem item = workflowProperties.Item; string amountRequested = item["Amount Requested"];

    .b

    Jesse Taber : I had a feeling it was something blatantly simple like that. Thanks, that's exactly what I needed.

0 comments:

Post a Comment