0

I am currently using SharePoint Online and creating SharePoint 2013 workflow using SharePoint Hosted App project in Visual Studio 2015.

My scenario is I want to create tasks at different stages and assign to different people, however each task is going to have different fields to input. Thus, I need to have custom task forms.

I can't use SharePoint designer as it is SharePoint App (Add-in).

When I was using On-Premise SharePoint 2010 workflow, I used to create different content types with Inherit="FALSE" and provide custom forms in XMLDocument tag which worked perfectly.

However, when I use below code for Content type which use Parent ContentType as Workflow Task (SharePoint 2013), it doesn't create task properly when you set Inherit='FALSE'. Workflow status page shows error in Tasks section stating 'One or more field types are not installed properly'.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Workflow Task (SharePoint 2013) (0x0108003365C4474CAE8C42BCE396314E88E51F) -->
  <ContentType ID="0x0108003365C4474CAE8C42BCE396314E88E51F0021934DF646F443608A44B2195BFFFADA" 
               Name="ctTestNewDemoApp5" Group="Custom Content Types" 
               Description="My Content Type" Inherits="TRUE" Version="0">
    <FieldRefs>
      <FieldRef ID="{06b88e60-36e5-419a-916f-69ab0dad77af}" DisplayName="Employee Name" Name="empName" />
    </FieldRefs>
    <XmlDocuments>
      <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">        
        <FormUrls xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
          <Display>Pages/Default.aspx?action=display</Display>
          <Edit>Pages/Default.aspx?action=edit</Edit>
          <New>Pages/Default.aspx?action=new</New>
        </FormUrls>
      </XmlDocument>
    </XmlDocuments>
  </ContentType>
</Elements>

Can we create custom 'Task forms' for new/edit/display purposes using Visual Studio? Please suggest.

Thank you, Sagar S.

0

I've got this working and here is the list of changes that I've made to make sure it works as expected.

  • Custom content type which must be inherited from parent content type Workflow Task (SharePoint 2013) (0x0108003365C4474CAE8C42BCE396314E88E51F), must also include the field of type 'OutcomeChoice'
  • Make sure to add ContentTypeBinding in 'Workflow Task List' inside Element.xml for this new Custom content type.
  • Make sure to have Workflow Task (SharePoint 2013) content type also present in the same ContentTypeBinding tag.

Please refer my working custom task content type with Custom form:-

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Workflow Task (SharePoint 2013) (0x0108003365C4474CAE8C42BCE396314E88E51F) -->
  <ContentType ID="0x0108003365C4474CAE8C42BCE396314E88E51F0021934DF646F443608A44B2195BFFFADA" Name="ctTestNewDemoApp5" Group="Custom Content Types" 
               Description="My Content Type" Inherits="FALSE" Version="0">
    <FieldRefs>
      <FieldRef ID="{06b88e60-36e5-419a-916f-69ab0dad77af}" DisplayName="Custom Outcome Column" Required="TRUE" Name="CustomOutcomeColumn" />
    </FieldRefs>
    <XmlDocuments>
      <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
        <FormUrls xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
          <Display>Pages/Default.aspx?action=display</Display>
          <Edit>Pages/Default.aspx?action=edit</Edit>
          <New>Pages/Default.aspx?action=new</New>
        </FormUrls>
      </XmlDocument>
    </XmlDocuments>
  </ContentType>
</Elements>

Please refer below Content type which has OutcomeChoice field

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">  
  <Field
       ID="{06b88e60-36e5-419a-916f-69ab0dad77af}"
       Name="CustomOutcomeColumn"
       DisplayName="Custom Outcome Column"
       Type="OutcomeChoice"
       Group="Custom Site Columns">
    <CHOICES>
      <CHOICE>Approved</CHOICE>
      <CHOICE>Rejected</CHOICE>
    </CHOICES>
    <Default>Rejected</Default>
  </Field>
</Elements>

Please refer below Workflow Task List instance:-

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance FeatureId="{f9ce21f8-f437-4f7e-8bc6-946378c850f0}"
              TemplateType="171"
              Title="WorkflowTaskList"
              Description="This list instance is used for workflow Task items."
              Url="Lists/WorkflowTaskList"
              RootWebOnly="FALSE" />


  <ContentTypeBinding ListUrl="Lists/WorkflowTaskList"
                       RootWebOnly="FALSE"
                       ContentTypeId="0x0108003365C4474CAE8C42BCE396314E88E51F"/>

  <ContentTypeBinding ListUrl="Lists/WorkflowTaskList"
                       RootWebOnly="FALSE" 
                       ContentTypeId="0x0108003365C4474CAE8C42BCE396314E88E51F0021934DF646F443608A44B2195BFFFADA"/>
</Elements>

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.