Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

AlterTask method gives Object reference not set error

$
0
0

Hi,

I have created a VS 2010 Sequential workflow.

I have a custom Task List, which has few additional columns as be:

I have used the CreateTaskwithContentType option. Contenttype has some value in fieldref.

//Below data is taken while debugging on the listitem of task on the Fields data

<FieldRef Name="PercentComplete"/><Field ID="{guid}" Name="RejectReason" StaticName="RejectReason" DisplayName="Rejection Reason" Type="Text" Group="Custom Site Columns" ColName="nvarchar5" SourceID="{guid}"/><Field ID="{guid}" Name="TaskApproverComments" StaticName="TaskApproverComments" DisplayName="Approver Comments" Type="Note" Required="TRUE" NumLines="8" RichText="TRUE" RichTextMode="FullHtml" IsolateStyles="TRUE" Sortable="FALSE" Group="Custom Site Columns" ColName="ntext4" SourceID="{guid}"/>


I am using the Alter Task method to update values.

Below is the code used:

Hashtable taskHash = new Hashtable(); 

taskHash["RejectReason"] = ddlReason.SelectedValue.ToString();

taskHash["TaskApproverComments"] = txtComments.Text;
taskHash["PercentComplete"] = "1"; 

// this._TaskListItem contains the task list item 

SPWorkflowTask.AlterTask(this._TaskListItem, taskHash, true); 

I have checked this:

http://social.msdn.microsoft.com/Forums/en-US/8b93979a-4bb6-49cc-a204-3d2677686270/nullreferenceexception-on-spworkflowtaskaltertask?forum=sharepointcustomizationlegacy

http://aarebrot.net/blog/2011/10/how-sloppiness-and-spworkflowtask-altertask-could-inadvertantly-lock-your-workflow-task/

Below is the content type, which i have associated:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"><ContentType ID="0x01080100Guid" Name="TestContentType" Group="Custom Content Types" Version="0"><FieldRefs><FieldRef ID="{guid}" DisplayName="Rejection Reason" Name="RejectReason" /><FieldRef ID="{guid}" DisplayName="Approver Comments" Required="TRUE" Name="TaskApproverComments" NumLines="8" Sortable="FALSE" /></FieldRefs></ContentType></Elements>

For the custom task list, as well as the workflow, i have used the same content type.

How to fix this?

Thanks



Viewing all articles
Browse latest Browse all 11571

Trending Articles