-1

I have created custom content type inherited from Workflow Task (SharePoint 2013) as i have to remove and add fields according to use.

I also created a custom workflow task list, which uses Task(default),Summary Task,Workflow Task (SharePoint 2013)(my custom content type),Workflow Task.

I have tried to make an exact copy Workflow Tasks, then associated workflow with document library.My custom Workflow Tasks is exactly same but, differs in Workflow Task (SharePoint 2013) which causes problem.

Workflow works fine with inbuilt Workflow Tasks but not with me custom list with custom content type.

I am doing all the things in Visual Studio programmatically. I think,my custom Workflow Task (SharePoint 2013) creates problem.

Elements.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Parent ContentType: Workflow Task (SharePoint 2013) (0x0108003365C4474CAE8C42BCE396314E88E51F) -->
  <ContentType ID="0x0108003365C4474CAE8C42BCE396314E88E51F00526BE6B656AD4301B5116F892EA5A019" Name="WorkflowCT" Group="Paperless CT Group" Description="Content Type for workflow" Inherits="TRUE" Version="0">
    <FieldRefs>
      <FieldRef ID="{E32A6287-4DE5-49F1-9133-9FD15364395B}" DisplayName="Comments" Name="WFComments" NumLines="6" ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE" />
      <FieldRef ID="{B7031F2B-19C3-4035-8FF0-775AD2160D79}" DisplayName="WF Task Outcome" Required="FALSE" Name="WFTaskOutcome" ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE" />
    </FieldRefs>
  </ContentType>
</Elements>   
  • Can you share the contents of your Task list instance Elements.xml file please – Submits Dec 19 '14 at 17:50
  • I am creating task list on Event Receiver i.e. FeatureActivated method – Vikas Bansal Dec 22 '14 at 3:40
  • Share your event receiver code then please – Submits Dec 22 '14 at 8:57
0

Yes, after a long hit and trial. Its working now. Create Workflow task list using Event Receiver only as this way the required content types will get automatically added.

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
  using (SPSite site = properties.Feature.Parent as SPSite)
  {
    using (SPWeb web = site.OpenWeb() as SPWeb)
     {
      string listName = "WFTaskList";

      // get instance of content type
      SPContentType workflowCT = web.ContentTypes["WorkflowCT"];
      // check that if list already exists or not
      bool isListExists = (from list in web.Lists.OfType<SPList>()
                              where list.Title.Equals(listName)
                              select list).Count() > 0;

      if (isListExists == false)
       {
         web.AllowUnsafeUpdates = true;
         web.Lists.Add(listName, "Custom Workflow Task List", SPListTemplateType.Tasks);
         SPList wfTaskList = web.Lists.TryGetList(listName);
         wfTaskList.ContentTypesEnabled = true;
         wfTaskList.ContentTypes.Add(workflowCT);
         wfTaskList.Update();
         web.AllowUnsafeUpdates = false;
       }
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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