Best practice for deploying multiple content types with dependencies in SharePoint - sharepoint

I'm developing a solution with approx. 15 custom content types. Therefore I created in Visual Studio a SharePoint Project and added content types defined in XML Markup.
As some of these content types use references between each other (Lookup-Columns), I added List Definitions and List Instances as well. As lookups can be declared in XML since SharePoint 2010 - everything's fine.
Now my feature contains all the content types, the list definitions and the list instances.
But the problem is: Sometimes the deployment succeeds and sometimes it fails. I suppose this may occur because the elements within the features have no activation order. Now I could change my project and create a feature for every content type and define acitvation dependencies to define an activation order. But this would lead to at least 20 features and in my opinion this can't be the supposed solution to handle this correctly.
What's the correct way to deploy content types with lookups to other content types within the same solution?
There's one restriction: everything has to be sandboxed because I want to deploy in SharePoint Online.

I believe I had the same problem as you - I defined two content types; A and B, B relied on A. and both were in the single feature. However when it came time to deploy I received an error:
Error occurred in deployment step 'Activate Features':
The parent content type specified by content type identifier 0x010029043F0D68EC4DF1BC85141AFF451661 does not exist.
I looked in the Manifest.xml file that Visual Studio generates inside the wsp/cab file and noticed the two content type Elements.xml files were defined the wrong way around:
B/Elements.xml
A/Elements.xml
A work around to this is to simply force the order of certain Elements.xml file in the feature (i.e. put the 'root' content type files first).
Open the feature, go to Manifest, open Edit Options and enter the file you need to be specified first in the list of Elements.xml files.
<ElementManifests>
<ElementManifest Location="A\Elements.xml" />
</ElementManifests>
This emits the following XML into the manifest file:
<ElementManifests>
<ElementManifest Location="A\Elements.xml" />
<ElementManifest Location="B\Elements.xml" />
</ElementManifests>

Related

Sharepoint online use the same new/display/edit forms for two or more libraries

I'm trying to develop a Sharepoint online site to show inventory of every departments. Since I have several thousands of items, I separate the items into several libraries by departments. Each library will have the same columns.
Currently, I'm facing a problem of how to standard the new/display/edit forms for all libraries. Of cause I can use library template to do so. But what if I need to update the form, e.g. add a reference link or change the layout? Then I need to modify the form one by one for each library.
Is there any solutions that I can create one master form so that (1) it can be applied to two or more libraries, and (2) whenever the master form is changed, the change is automatically applied to the libraries?
Thanks
This is a great use case for Content Types.
At the Site Settings level, Create the columns you want. Then create the Content type you want, called "Inventory" for example. Add the columns to that Content Type.
Add the content type to each library.
Library Settings -> Advanced Settings -> Allow Management of Content Types
Remove the default content type from the library settings page
Now, you can update the columns at the site Content Type level, and it will publish to and update each library.

Biztalk template with non-static namespace - Visual Studio

I've exported an orchestration template using Visual Studio 2012, based on one I previously constructed. It generates a .zip with the following .vstemplate file:
<VSTemplate Type="Item" Version="2.0.0"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>TESTOrchestration</Name>
<Description>Custon Orchestration</Description>
<Icon>Icon.ico</Icon>
<ProjectType>Biztalk</ProjectType>
<DefaultName>TESTOrchestration.odx</DefaultName>
</TemplateData>
<TemplateContent>
<ProjectItem TargetFileName="$fileinputname$.odx" ReplaceParameters="true">Orchestration.odx</ProjectItem>
</TemplateContent>
Using this item template in VS2012 creates an orchestration with the properties shown in the fig. below.
Notice the namespace is that of the original project from which the template was exported.
I want to set the default namespace of this item to include the project name (or even better the path leading to this item within the project). After searching I've yet to find a working example of how to accomplish this in a BizTalk item, namely an .odx.
Thank you for taking the time to read my question. I really hope you will be able to help me with this.
After searching and tinkering around I found out how to accomplish this.
When you export a template from Visual Studio two files are created, a .vstemplate and a template of the exported item, in this case a .odx. In order to alter the namespace, and other attributes, you need to edit this second file and add the information you want.
It is also possible to pass dynamic values by using template parameters in the form of $parameter$, which are documented in Microsoft's library.
So, for example, if you wanted to modify the namespace to include the project name, you would have to edit the exported .odx file and add the parameter $safeprojectname$ or $rootnamespace$ to dynamically set the namespace uppon creation of a new item based on the template.

Adding a custom t4 template to DDL Generation Template dropdownlist

I know I can add the template in the folder
C:\Program Files (x86)\Microsoft Visual Studio
11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen
to make it visible in the DDL Generation Template dropdownlist, but then I need to distribute the template to my team members so they can add the template to the same folder.
I was hoping that I could achieve the same result by adding the template to the VS 2012 solution somehow and make it visible in the same dropdownlist
Do you know a way to achieve this?
I'm using VS 2012 and to generate the database I use Model First approach
I played around with this tonight and found it is possible, but it's kind of a hack. You'll have to edit your edmx file by hand, and make sure it is version controlled because you have to edit the designer section of the edmx file (auto-generated). First thing is to copy the t4 template to the root of your project (might actually have to be in the same folder as the edmx, not sure). Then add the t4 template to your project. Now remove the custom tool entry (in properties) so it doesn't try and auto gen the t4 template. finally add the designer property below in the correct location in the edmx file (i included context to find the right place):
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
<edmx:Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="DDLGenerationTemplate" Value="SSDLToSQLite3.tt" />
I ended up making a custom template to generate datetime2 fields. Although I could not get the template to show in the drop down in the properties box, I was able to add the template to the same folder as my .edmx, include it in the solution, then type the file name of the template directly into the designer's property field replacing the default. The value appears to be retained after generating databases and entities, I didn't need to directly edit the edmx XML, and my custom template is now source controlled right next to where it is used.

Custom SharePoint List View - can I put it in a feature (WSP)?

Here's my situation:
I'm working in SharePoint 2007 Enterprise, I have a feature that creates a list for me when I deploy and activate it. My usual workflow thus far has been to deploy the solution, activate it, then open up SharePoint Designer to customize the list.
My customizations are typically pretty complex, but I'll keep things simple. In this case, let's just say that I edit AllItems.aspx, convert the data view to an XSLT data view, then I add one column with static text.
I've used a few different tools (SPSource, VSeWSS, SharePoint Manager, OCDExportList, etc) to extract my custom schema.xml and all the default views, but I have yet to have any luck figuring out where the the code for AllItems.aspx is now that it's been customized.
When I extract (using any of the tools above) AllItems.aspx is no different than the default. The <View> element in schema.xml is reduced to one line, for example:
<View DefaultView="TRUE"
MobileView="TRUE"
MobileDefaultView="TRUE"
Type="HTML"
FPModified="TRUE"
DisplayName="All Documents"
Url="Forms/AllItems.aspx"
Level="1"
ContentTypeID="0x" />
I'm really stuck here... I've got no clue what to do. Is it even possible? It would save me a great amount of time (and documentation) if I could include my customizations in my feature.
If there's any other info I'm missing that would help, let me know... thanks!
Latest findings:
I've found out a bit more in the past couple hours. If I save the list as a List Template, then save the .stp file locally as a .cab file I can extract its contents. One of the files is manifest.xml which contains the schema.xml as well as a few other sections.
One of those sections is a <webparts> section that has a <webpart> for each view. Each of those <webpart> elements contains a really long string of characters... no clue what those characters actually represent.
The important thing is that I think any custom views have to actually be Web Parts if deployed as part of a solution... but I'm not positive.
I have faced a similar issue a while ago. I had to create a very customized view and I had to give up the ListFormWebPart completely, and have created my own webpart to render the data.
Generally, when you customize the aspx file in SPDesigner, all your changes will be in the aspx file itself. Open it in SPDesigner and you will see there all the changes you have made. After you have converted to the XSL Data View, the standard ListFormWebPart is replaced by a DataFormWebPart, which doesn't care about the <View> tags specified in the schema.xml; Look in the aspx file itself for the ListFormWebPart.
Why not do all the customizations you want on a list, save the list as a template (it will include the associated AllItems.aspx) and then use that template in your feature to create your list? You could add the extracolumn from code (if it's dynamic and cannot be included in the template), and so on.
Yes you can. Get the Sharepoint manager tool from Codeplex
http://spm.codeplex.com/
Install it on a machine in your farm, it will allow you to browse the farm via a tree view that shows all objects.
Make the list via the Sharepoint GUI, then browse to it w/ SPM.
SPM will allow you to extract the MOSS/WSS created xml that describes the list view (it shows up in the left hand property grid), which you can then plop into your manifest.xml
I have a similar issue and have been doing a lot of research into this. The dataview web part to me is one of the most powerful components in Sharepoint. Unfortunately I have to provide my solution as a .wsp package and that means that I can not just make the site and use Designer on that site. I have taken a 2 step approach in that I used designer to create my dataview and I also edited the code of that dataview to replace the ListID and Guids to ListName and the actual list name. This allows it to be exported and used in any page/site as long as the list name is the same. I am creating a webpart page document library also in my solution and I believe I can add the pages that have the webparts to this library using the onet.xml file. I will try to get the results of that test in as soon as I can do it.

Deployment of custom content type, forms, cqwp, and xsl

Right now I have a visual studio project which contains a custom content type that I made. It also contains all the necessary files for making a sharepoint solution (wsp) file and a script to generate this.
Now, I would like to do 2 things.
First, I'd like to create a custom display form for the content type and include it in my solution so that it is automatically deployed when I deploy my solution. How do I include this in my solution and make my content type use it?
Secondly, you can query this type with the CQWP. I've thought about exporting it, adding more common view fields, and then modifying the XSL that is used to render it. How do I include this into my solution so that it is also deployed. I know i can export the CQWP webpart once it's all setup and include it in my project as a feature. But what abuot the XSL?
Looking forward to see your suggestions, cheers.
Did as described in the first answer. Worked like a charm.
Use STSDev to create the solution package.
That should help with creating the WSP. The custom form, CQWP webpart and the .xls file should also be deployable within the project.
To deploy the xslt, your feature will have an
<ElementManifest Location="mywebpartManifest.xml">
This then points to a files such as
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Yourfile.xslt" Url="Style Library" Path="" RootWebOnly="TRUE">
<File Url="yourfile.xslt" Type="GhostableInLibrary" />
</Module>
</Elements>
for the webpart:
<Module Name="myWebpart" List="113" Url="_catalogs/wp" RootWebOnly="FALSE">
<File Url="myWebpart.webpart" Type="GhostableInLibrary" />
</Module>
Now that file will need to be contained in the solution manifest.xml. This is done automatically from the STSDev project.
e.g.
<Resources>
<Resource Location="SimpleFeature\Feature.xml"/>
The actual schemas are:
Site
Solution
Feature
and a link to someone else with the issue
But where in the folder structure do you deploy the form and the .xsl to?
I have followed your guide and although it deploys the xslt to the feature in 12 Hive it does not place it in the correct style library folder
You need to deactivate / reactivate the feature. This will give you any error messages that are associated with copying the file over.

Resources