Visual Studio Developer Center > Visual Studio vNext Forums > SharePoint 2010 - Using Visual Studio with SharePoint and other programming > cannot register custom edit form through a content type and deploy it as a feature

Answered cannot register custom edit form through a content type and deploy it as a feature

  • Friday, April 30, 2010 6:55 PM
     
      Has Code

    custom edit form through a content type and deploy it as a feature.. the RTM version of sharepoint 2010 does not register the custom forms. the elements.xml is pretty straight forward..

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
     <!-- Parent ContentType: Workflow Task (0x010801) -->
     <ContentType ID="0x010801007fc29cb23c2049c3985ccdb95fc8331f" Name="ReviewTask" Group="Content Types" Description="Review workflows task purpose" Inherits="TRUE" Version="0">
      <FieldRefs>
       <FieldRef ID="{2C2BE3C6-0EB6-4F53-B612-CF49A7EF4013}" Name="Review Status" />
       <FieldRef ID="{CE1D0566-DDC6-4AA3-80C2-6CEA892F105E}" Name="Review Date" />
       <FieldRef ID="{07CB9AA2-0102-4741-9F9A-AC4A7D62D769}" Name="Review Comments" />
      </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/My/ReviewTaskEditForm/TaskEditForm.aspx</New>
         <Display>_layouts/My/ReviewTaskEditForm/TaskEditForm.aspx</Display>
         <Edit>_layouts/My/ReviewTaskEditForm/TaskEditForm.aspx</Edit>
        </FormUrls>
       </XmlDocument>
      </XmlDocuments>
     </ContentType>
    </Elements>

    Am I misssing something.. NamespaceURI ? Bug ??

    I have tried taking an example of the already installed features that came out of box

    MSDN documentation is of no help currently ( http://msdn.microsoft.com/en-us/library/ms473210(v=office.14).aspx )

    Please let me know

    Thanks, Mano

Answers

  • Friday, May 28, 2010 4:34 AM
     
     Answered

    I reproduce the bug.... it looks like the attributes Inherits="TRUE" cause this behavior... just remove it and it will be ok!

    Regards!

All Replies

  • Saturday, May 01, 2010 1:10 AM
     
     

    Hi Mano,

    Can you give a little more details. When are you getting an error and what is the error? Also, how are you deploying the xsn forms?

    Thanks!


    Huma Qureshi SDE, Visual Studio
  • Saturday, May 01, 2010 4:27 AM
     
     

    Hi Huma,

    I dont get an error, the query is that I dont get the intended outcome.

    Basically, I am trying to create a content type with custom edit forms. These forms are not infopath forms .. but are aspx forms.

    Steps to reproduce..

    Open an empty sharepoint project and added a new item of the type Application Page.

    THen I added another item of the type 'Content Type' and modified the elements.xml as above.

    Also I create a feature and When deployed, I can see the content type in my site collection with the columns I referenced too.

    To test the custom forms, I apply the content type to a list and create a new item if the custom content type. What I expected was my custom form to show up, but instead I get the default out-of-box form.

    If I open SharePoint designer, and navigate to the site content type which I deployed, I see that the editformurl and displayformurl values are empty.

    I can enter the vaues through designer, and then I test to see that my custom form is displayed when I edit List item.

    Again, the issues is, if I define a contenttype using VS2010, which includes custom edit forms, and deployed as a feature.... the contenttype is available in my site collection, but edting an list item will show default forms instead of my custom forms

    Thanks for your help

    -mano

  • Friday, May 21, 2010 5:07 PM
     
     

    Hi,

    I have the same problem and i want to develop an aspx task base WorkFlow, any solutions ?

    Thanks,

    Patrice

     

     

     

  • Sunday, May 23, 2010 2:23 AM
     
     
    I also have the same issue. Can someone please shed some light on the situation? Is this not the proper way to define the custom forms for a Custom Content Type?
  • Sunday, May 23, 2010 2:39 AM
     
     

    I do not test this but im pretty sure that what you are doing is incorrect. List form should not be deployed in the layouts folder but as an SPFile (ghosted) added by a feature using a "Module" element...

     Why? Because list form are webpart pages and that layouts pages (which are commonly called application pages) are not webpart pages...They should be used for site configuration or anything else that is related for administration or configuration task....

  • Sunday, May 23, 2010 2:37 PM
     
     

    I have seen a couple of walkthroughs for WSS3.0 doing this in the fashion of the original post (having them in the layouts folder).

    This site: http://msdn.microsoft.com/en-us/library/ms473210(v=office.14).aspx mentions having the path relative to the root location of the content type. What does that mean? Has anyone found any other useful information on this topic in MSDN or another site?

  • Sunday, May 23, 2010 8:38 PM
     
     Proposed Answer Has Code
    I have gotten this to work by setting the form url's programatically. For example, I had this code execute on a createTask_MethodInvoking call in a workflow. Try it out, let me know if it works for you.

    using (SPSite sitecollection = new SPSite("http://mysite"))
    {
       using (SPWeb web = sitecollection.OpenWeb())
       {
          SPList list = web.Lists["mylist"];
          SPContentType ct = list.ContentTypes["my type"];
              
          ct.EditFormUrl = "_layouts/whatever/page.aspx";
          ct.DisplayFormUrl = "_layouts/whatever/page.aspx";
          ct.NewFormUrl = "_layouts/whatever/page.aspx";
          ct.Update();
          list.Update();
       }
    }

    • Proposed As Answer by Kyle W. Smith Sunday, May 23, 2010 8:38 PM
    •  
  • Thursday, May 27, 2010 2:08 AM
     
     

    Mano, have you already deployed your content type in the site collection prior to add the form urls in the definition?

    Im only asking this cause change to existing content type will, in most case, not work by only changing the xml definition and redeploy it...

    In this case you need to write a feature upgrade and use the code provide by Kyle to do the job....

    If you dont like feature upgrade ou could only execute a patch like one shot that does the same..

    If you dont like that either you could also delete all existing items related to that content type (maybe export them before) then redeploy your content type definition wich will be updated this time and then reimport exported items.

     

  • Friday, May 28, 2010 1:36 AM
     
     
    This is one way to do it. Sharepoint Designer provides a easier way to set the forms. But the issue is with creating a xml and deploying.
  • Friday, May 28, 2010 1:40 AM
     
     

    Are you trying to update the content type xml definition or are you creating a new one?

     

    If you are trying to update an existing one... is there items created having this content type in the target site collection?

  • Friday, May 28, 2010 1:43 AM
     
     
    Raevean, no I did not deploy the content type prior to adding the forms. The content type and the layout forms are all packaged in one wsp solution package.
  • Friday, May 28, 2010 1:55 AM
     
     

    I do not test this but im pretty sure that what you are doing is incorrect. List form should not be deployed in the layouts folder but as an SPFile (ghosted) added by a feature using a "Module" element...

     Why? Because list form are webpart pages and that layouts pages (which are commonly called application pages) are not webpart pages...They should be used for site configuration or anything else that is related for administration or configuration task....


    Raevean, maybe it is not right to have forms in layout folder, but I have found some out of box contenttypes using forms in layouts folder. But your point is noted. Thanks.
  • Friday, May 28, 2010 1:57 AM
     
     

    Let me try this fix this and be back to you

  • Friday, May 28, 2010 4:14 AM
     
      Has Code

    This definition work for me...

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
     <!-- Parent ContentType: Task (0x0108) -->
     <ContentType ID="0x010800E64F1CE8C2464C608F8063275CDB5417" Name="My.SharePoint.ContentTypes - ReviewTasks" Group="Custom Content Types" Description="My Content Type">
     <FieldRefs>
      
     </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>_layouts/My.SharePoint.ContentTypes/test.aspx</Display>
       <Edit>_layouts/My.SharePoint.ContentTypes/test.aspx</Edit>
       <New>_layouts/My.SharePoint.ContentTypes/test.aspx</New>
      </FormUrls>
      </XmlDocument>
     </XmlDocuments>
     </ContentType>
    </Elements>
    

     

    I would suggest that you start with a simpler form of your content type to make it work then add other stuff to it when you get it work...
  • Friday, May 28, 2010 4:34 AM
     
     Answered

    I reproduce the bug.... it looks like the attributes Inherits="TRUE" cause this behavior... just remove it and it will be ok!

    Regards!

  • Friday, September 24, 2010 10:25 AM
     
     

    Hello Raevean,

    I am trying to accomplish this same task but with no success. I have tried all the above solutions as suggested by you all.

    I am developing on SharePoint Server 2010 using Visual Studio 2010.

    Please help me out.

    Thanks in advance...


    Regards,Gautam Kaikini, SharePoint Developer. http://in.linkedin.com/in/gautamkaikini
  • Friday, November 26, 2010 12:02 PM
     
     

    If I remove the Inherits, Visual Studio allows me to deploy the content type only once.

    Error 6 Error occurred in deployment step 'Activate Features': The content type with Id 0x010801002D200B2F39304708888CF05CDEA12F9C defined in feature {b329590d-f64e-40bb-91a9-e7bfb021c037} was found in the current site collection or in a subsite.

    Any suggestion?

  • Thursday, January 06, 2011 11:19 PM
     
     

    So the only way to create custom forms for a content type is by not inheriting from another content type and setting the forms afterwards programatically?

    There's got to be a better way... I want to inherit and  have custom forms...

  • Thursday, May 12, 2011 3:25 PM
     
     

    Had same problem because of wrong NamespaceURI and xmlns!