คำตอบ Content types in Visual studio

  • 11 พฤษภาคม 2555 15:18
     
     

    Hi

    I'm creating a workflow in VS and require custom pages and custom content types. I'm planning on using 'feature' of Visual Studio to deploy.

    Should the Content types, Pages and Workflow reside in one Project ? or should they be seperatly installed ?

    In visual Studio I can see it has templates for content types and State machine workflows, didnt know if its better to keep them in separate projects.

    Thanks 

ตอบทั้งหมด

  • 11 พฤษภาคม 2555 15:33
     
     
    This is up to you. You can develop multiple features in one project and deploy from one WSP. This is more design question. If you will share one feature across multiple projects maybe make sense to develop it in separate project.

    Oleg

  • 11 พฤษภาคม 2555 19:09
     
     คำตอบที่เสนอ

    It is better to keep content types in a seperate project and configure feature dependency in other projects pointing to content type project. This way you dont mess up with other project updates. Usually i make content type project after making sure all of the business folks or project owners finalize them. so that we should only push it once. Once content type is deployed through feature activation, It would not make sense to retract the solution to push an update in content types etc. I have seen sharepoint odd behaviours when pushing out updates through features. so I usually deploy content types to other servers at very final stage of the project. so that we dont run into making changes stage. If you ever have to make an update to Content type after you deploy to a server, i always prefer to just make it in browser directly. For other things like workflows, updates in solution always occur after you initially deploy them due to functionality updates/enhancements. so thats why content type project should be kept seperatly from other development components.


    Moonis Tahir MVP SharePoint,MCTS SharePoint 2010/2007, MCPD.net, MCSD.net, MCTS BizTalk 2006,SQL 2005

    • เสนอเป็นคำตอบโดย Ravi S Kulkarni 12 พฤษภาคม 2555 8:19
    •  
  • 12 พฤษภาคม 2555 8:44
     
     

    Hi Thanks for your points.

    I think i will create Content Types seperatly.

    I have another issue. Previously I created Content Types using notepad. I used 3 files 1 for ct, 1 for fields and 1 for feature. I used 0x0108 as the parent CT. In my browser when I look at CT I can see Workflow Task as the Parent. This is what I expected.

    I tried to replicate this in VS. When I start VS templates I chose CT, amongst all CT I cannot see Workflow task, so I chose Task. The code displays with 0x0108....

    After deploy in the browser it shows up as 'Task' and not 'Workflow Task'.

    when running wf i get error

    The content type of a workflow task must be derived from the Workflow Task content type.   

    Any ideas ?


  • 12 พฤษภาคม 2555 10:46
    ผู้ดูแล
     
     

    Sharepoint developer tools do not allow you to create a Content Type that inherits from WorkflowTask when you use the Sharepoint Customization wizard. Instead you have to edit the elements.xml for the Content Type manually after you create it. The Content Type ID for workflow task content ID is 0x01081. In your elements.xml you have to create a unique id starting with this ID, eg. 0x01081783fe326d347...


    Regards Bjoern
    Blog

  • 12 พฤษภาคม 2555 11:06
     
      มีโค้ด

    Thanks

    And finally I have now added forms to my CT. A task is being generated but the custom form is not loading, only the default, I can see the custom field. Am I missing some code in my CT xml file ?

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      
    <Field ID="{E7434B72-C699-425B-9F99-193ED36CE673}" Name="CardTransConfirmed" DisplayName="Card Transaction Field" Group="Custom DT Fields" Type="Note" NumLines="10" Required="FALSE" /> 
      <!-- Parent ContentType: Task (0x010801) -->
      <ContentType ID="0x01080100e564662209dd4aea992778476bb88377"
                   Name="DT_CT"
                   Group="Custom Content Types"
                   Description="My Content Type"
                   Inherits="TRUE"
                   Version="0">
        <FieldRefs>
          <FieldRef ID="{E7434B72-C699-425B-9F99-193ED36CE673}" Name="CardTransConfirmed" DisplayName="Card Transaction Field" />
        </FieldRefs>
        
        <XmlDocuments>
          <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
            <FormUrls xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
              <New>_layouts/CustomApprovalForms/ApprovalForm.aspx</New>
              <Display>_layouts/CustomApprovalForms/ApprovalForm.aspx</Display>
              <Edit>_layouts/CustomApprovalForms/ApprovalForm.aspx</Edit>
            </FormUrls>
         </XmlDocument>
       </XmlDocuments>
        
      </ContentType>
    </Elements>



  • 12 พฤษภาคม 2555 12:00
    ผู้ดูแล
     
     
    How did you create your form,  did you use any any of the Work flow form item templates (association form and initform), Infopath or did you create everything from scratch ?

    Regards Bjoern
    Blog

  • 12 พฤษภาคม 2555 14:44
     
     

    Hi

    Created form all from scratch. Does the above code appear correct ?


  • 12 พฤษภาคม 2555 16:15
    ผู้ดูแล
     
     คำตอบ

     Try comparing your project with this great tutorial, then hopefully  you'll see what you have missed.


    Regards Bjoern
    Blog