views:

465

answers:

2

I am making a sharepoint state machine workflow. The first state has a "create task with content type" as the task. The content type has a field called "isApproved". I am not using any infopath forms. I am trying to get the value o fthat field to evaluate if the document is approved or not. No matter what I do I am getting "object not set to an instance of an object".

I have tried all of the following:

createTaskWithContentType1_TaskProperties1.ExtendedProperties["isApproved"].ToString();
onTaskChanged1_AfterProperties1.ExtendedProperties["isApproved"].ToString(); 
onTaskChanged1.AfterProperties1.ExtendedProperties["isApproved"].ToString();

What am I doing wrong???

A: 

I had similar problems once, and I had to get the field ID to access the field. This is how I did it:

Guid isApprovedFieldId = worflowProperties.TaskList.Fields["isApproved"].Id;  
string approvalStatus = (string)(onTaskChanged1_AfterProperties1.ExtendedProperties[isApprovedFieldId]);
Abs
A: 

I know this answer comes too late but I figured lots of people acome accross this posting...

The field "isApproved" is a function of the infopath task form usually used by msft in example workflows. This field is certainly not available in basic content type tasks which are really just simple SharePoint task forms completely unrelated to InfoPath and the "isApproved" field. What you will need to do is grab the afterprops of the task, query the "status" field and determine if the user completed the task. If you added another column to the task called "Approved" then query that field using the taskItem["fieldName"] method and not [Extended Properties].

Hope this helps somebody!

UJ