I've created a custom list (PBE) and attached a workflow which creates a task. When I edit the task, I am in my custom task form (.aspx)

I want to check a value in a field in my orginal custom list (pbe). The url passed to the custom task form has several parameters, but I think list = task list. In ID parameter I can see the original list guid.

Is it possible to retrieve the orginal PBE data through the task list or do I need to edit the url ID field, saying this I dont have a reference to the item itself ?

I'm coding in c# and using Visual Studio.

1 Answer 1


You can retrieve item from workflow properties and set IDs of PBE item and list to extended properties of task

taskProperties.ExtendedProperties["ItemId"] = item.ID;
taskProperties.ExtendedProperties["ItemListId"] = item.ParentList.ID;

Then you can retrieve these values in your custom task form like this

Hashtable extendedProperties = SPWorkflowTask.GetExtendedPropertiesAsHashtable(task);
var listId = extendedProperties["ItemListId"];
var itemId = extendedProperties["ItemId"];

You can access to the field like this

var list = web.Lists[listId];
var item = list.GetItemById(itemId);
var fieldValue = item[fieldId];
  • Hi Thanks for this information, In my Custom Task Form I now have the two variables. listId and itemId. How Can I grab a field in the list with a certain ID ? Commented Jan 4, 2012 at 15:35
  • I updated my answer. If you want to get field, not a value of field, you can use list.Fields[fieldId] method.
    – Alexander
    Commented Jan 4, 2012 at 16:00
  • HI I accessed the fields like this, though it works its more complex, have I done it the long way ? this._sharePointListAttachedTo1 = this._myTeamSite.Lists[new Guid(listId)]; this._listItemObject1 = this._sharePointListAttachedTo1.GetItemById(Convert.ToInt32(itemId)); Label5.Text = Convert.ToString(_listItemObject1["AT pbe entry user"]); Commented Jan 4, 2012 at 20:19
  • Wheres a good place to learn about these classes and methods ? Not too keen on the msdn site.. Commented Jan 4, 2012 at 20:25
  • I know only one site for this. it is a Google.com ;)
    – Alexander
    Commented Jan 4, 2012 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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