R – Sharepoint – trying to get value of a task field into a workflow

sharepointworkflow

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???

Best Answer

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]);  
Related Topic