Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

How to alter SP2013 workflow task from ASP task form?

$
0
0

Hello

I have created SPD workflow with a custom ASP form. My form opens when clicking on a task link and I can show information about the task. Now I want to alter the task after pressing a button, but can't make it work.

Code of my click handler:

Hashtable hashTable = new Hashtable(); this._taskListItem["PercentComplete"] = 1;

SPWorkflowTask.AlterTask(this._taskListItem, hashTable, true);

but it seems like this approach doesn't work, I am getting the following error:

NotSupportedException. Specified method is not supported. at Microsoft.SharePoint.Workflow.SPWorkflowTask.SetWorkflowData(SPListItem task, Hashtable newValues, Boolean ignoreReadOnly) at Microsoft.SharePoint.Workflow.SPWorkflowTask.AlterTask(SPListItem task, Hashtable htData, Boolean fSynchronous) at NewServerForms.Layouts.NewServerForms.ApprovalTaskForm_Edit.btnSubmit_Click(Object sender, EventArgs e)

_this.taskListItem is not null (I have checked it) and was initiated as follows in the Page_Load:

this._listGuid = Request.Params["List"];
this._listItemId = Request.Params["ID"];
using (SPWeb web = SPContext.Current.Site.OpenWeb())
{
   this._taskList = web.Lists[new Guid(this._listGuid)];
   this._taskListItem =  this._taskList.GetItemById(Convert.ToInt32(this._listItemId));
}

I have two ideas, why it is hapenning:

1. Probably I have to use another approach for SP2013 WFs.

2. As I can see in msdn, this error could be if my content type is not derived from WorkflowTask Content Type.

Most likely it is really the latter, because my task content type looks as follow:

<?xml version="1.0" encoding="utf-8"?><Elements xmlns="http://schemas.microsoft.com/sharepoint/"><ContentType ID="0x0108003365C4474CAE8C42BCE396314E88E51F00F35251B8B0C24C4986783D649A695D00" Name="TaskApproveNewServer" Group="MyGroup" Description="MyCT" Version="0" Overwrite="TRUE"><FieldRefs><FieldRef ID="{6f78c128-5660-4835-9b03-4c08d5eef709}" DisplayName="AbsenceStatement_Status" Required="false" Description="" Hidden="false" Name="AbsenceStatement_Status" Sealed="false" /><FieldRef ID="{55B29417-1042-47F0-9DFF-CE8156667F96}" DisplayName="$Resources:_FeatureId57311b7a-9afd-4ff0-866e-9393ad6647b1,TaskOutcomeField_DisplayName;" Name="TaskOutcome" Sealed="FALSE" /></FieldRefs><XmlDocuments><XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url"><FormsUrl xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url"><Display>_layouts/15/NewServerForms/ApprovalTaskForm_Edit.aspx</Display><Edit>_layouts/15/NewServerForms/ApprovalTaskForm_Edit.aspx</Edit></FormsUrl></XmlDocument></XmlDocuments></ContentType></Elements>

Its ID derived from WorkflowTask, but there is no Inherits="TRUE" attribute (it was removed, because I can't use custom forms when it is true because of the well-known issue).

So, could you suggest me, how can I alter the task using my custom ASP form?

Every suggestions are very appreciated.

UPDATE1:

It seems like the cause of the issue the former. At least, now I added Inherits="TRUE" attribute (and set forms from the Feature receiver), but anyway I am getting the same error.

Kind regards, Michael



Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>