SharePoint : Feature basics - sharepoint

I have this feature
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="c54f20d8-1ad1-49b8-aff7-2c874dd2f45a"
Title="MyCompany Content Types"
Description="Content Types required for MyCompany Provided Applications and Functionality"
Version="12.0.0.0"
Hidden="FALSE"
Scope="Site"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="siteColumns.xml"/>
</ElementManifests>
</Feature>
Here is the contents of siteColumns.xml
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field
ID="{1F343F02-22D9-45b8-A2A8-CEB2619A28C4}"
Name="AllowSubstDelivery"
DisplayName="AllowSubstDelivery"
Type="Boolean"
Format="TRUE"
Group="MyCustomGroup"
/>
</Elements>
The feature installs and activates, without producing an error, but the siteColumn is nowhere to be found, any ideas why this site column is not visible?
I checked the logs, no errors reported either.

Hmmm... it looks like you have done everything correctly. Did you copy and paste the ID for the Field from anywhere? If so, the ID may already be in use causing your Field provision to be ignored.
I find the best way to create a Feature defining Site Columns and Content Types is to prototype everything using the Web interface and then copy and paste the generated CAML into your Visual Studio projects. I recorded a short video demonstrating the process that you may find valuable.
SharePoint Site Columns and Content Types via a Feature

What does Format="TRUE" mean?
Doesn't look like it's according to documentation.
Field Element Documentation doesn't tell you much about those properties, however there is much in common with FieldRef element and it has documentation about Format attribute.
Maybe you wanted to use DefaultValue attribute?

Related

In Hybris backoffice how do I add another tab in explorer tree for managing (create, search, delete) instances of some items?

In Hybris Back Office, how do I add another tab in the explorer tree for managing (create, search, delete) instances of some items?
I can't really find anything on the subject.
Do I need to use the already available UI for it or add my own widget?
In your *-backoffice-config.xml file, you have to add something like this
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config xmlns="http://www.hybris.com/cockpit/config"
xmlns:y="http://www.hybris.com/cockpit/config/hybris"
xmlns:wz="http://www.hybris.com/cockpitng/config/wizard-config"
xmlns:list-view="http://www.hybris.com/cockpitng/component/listView"
xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea"
xmlns:explorer-tree="http://www.hybris.com/cockpitng/config/explorertree"
xmlns:simple-search="http://www.hybris.com/cockpitng/config/simplesearch"
xmlns:advanced-search="http://www.hybris.com/cockpitng/config/advancedsearch"
xmlns:df="http://www.hybris.com/cockpitng/component/dynamicForms"
xmlns:dsb="http://www.hybris.com/cockpitng/config/dashboard"
>
<context merge-by="module" parent="auto" component="explorer-tree">
<explorer-tree:explorer-tree xmlns:explorer-tree="http://www.hybris.com/cockpitng/config/explorertree">
<explorer-tree:navigation-node id="backoffice.myCustomItemType">
<explorer-tree:type-node code="MyCustomItemType" id="MyCustomItemType"/>
</explorer-tree:navigation-node>
</explorer-tree:explorer-tree>
</context>
<context type="MyCustomItemType" component="listview">
<list:list-view xmlns:list="http://www.hybris.com/cockpitng/component/listView">
<list:column qualifier="customAttribute1" />
<list:column qualifier="customAttribute2" />
</list:list-view>
</context>
</config>
Like way, you can configure "editorArea", "advanced-search", "create-wizard" etc by refering any OOTB backoffice-config.xml file.
Find this document for the steps.

Deploy ContentType with DocumentTemplate

First of all I created a few test columns...
Secondly I created a new content type (derived from Document).
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID="0x0101000F16F9EDC2D547C48480B02B918168DD" Name="MyDocContentType1" Group="Custom Content Types" Description="My Document Content Type 1" Inherits="TRUE" Version="0">
<FieldRefs>
<FieldRef ID="{d17ecdc8-991a-4efc-a758-bbb522dd2f62}" DisplayName="My Test Column 1" Required="FALSE" Name="MyTestColumn1" />
<FieldRef ID="{8e9ef300-b566-4939-8b3c-760e13afb6d5}" DisplayName="My Test Column 2" Required="FALSE" Name="MyTestColumn2" />
</FieldRefs>
<DocumentTemplate TargetName="~site/_cts/MyDocContentType1/MyDocumentTemplate1.dotx" />
</ContentType>
</Elements>
Next I created a module deploying my word 2013 template file (.dotx) to /_cts//MyCustomTemplate1.dotx
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="DocumentTemplates" RootWebOnly="TRUE" Url="_cts/MyDocContentType1">
<File Path="DocumentTemplates\MyDocumentTemplate1.dotx" Url="MyDocumentTemplate1.dotx" Type="Ghostable" />
</Module>
</Elements>
Adding the content type to a library enables the document template...
E.g. when I create a new item of "MyDocContentType1" it opens up Word 2013.
However the document template is not correctly bound to the server - the document information panel doesn't appear and I cannot add any quick parts refering to sharepoint content type columns.
It does work when I assign the document template via the SharePoint Web UI.
Any ideas?
Edit: The word template (.dotx) is already aware of the SharePoint columns. In a previous step I assigned the DocumentTemplate manually (to design the word template). Now that the .dotx template is feature complete I want to deploy it as part of a SharePoint solution (for example to a newly created site collection).
Edit: Of course it works using a programmatic approach assigning the DocumentTemplate property via feature event receiver. That's not the solution I am looking for. Declarative only.
To me it looks like a bug. If I go to the content type, edit/update the document template (updating - not uploading a new one!) and create a new document from that content type it starts to work... ?!
I am going to assume that you created your *.dotx file directly in word and added it to Visual Studio.
The reason why it doesn't work is that the dotx file needs to have references to the SharePoint fields encoded in the Word file itself.
I would suggest to:
Deploy your content type without any document template
Add the content type to a document library
Edit the newly created list content type (inside the document library) and upload a blank empty *.dotx template: now SharePoint will create a copy of your dotx file, add all the content type columns, and save the new dotx file in the Forms/ folder in your document library ; After this, you have a blank dotx file with the correct associations - test it by adding a new document in your document library with your content type and check the information panel
Open the document library in SharePoint Manager (or with SharePoint Designer, or navigate to the Forms/ folder) and download the SharePoint-generated dotx file
Customize this dotx file to your needs
Delete the document library and retract your wsp package
add the final dotx to your solution and your content type just like you did before

Manifest file for registration of event handler in SP 2007

I'm trying to create a feature to register my event handler to a specific list. I'm building it like I would a normal feature. However, I'm not sure how to define my Elements file. The file for my feature is as follows:
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListTemplateId="101">
<Receiver>
<Name>AddedEventHandler</Name>
<Type>ItemAdded</Type>
<SequenceNumber>10000</SequenceNumber>
<Assembly>ChangeContentTypeEventHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bfc7c17f98031d7</Assembly>
<Class>ChangeContentTypeEventHandler.ChangeContentTypeEventHandler</Class>
<Data></Data>
<Filter></Filter>
</Receiver>
</Receivers>
</Elements>
Based on this, how would I set up the file for registration of this event handler?
Also, here is my Feature.xml file:
<?xml version="1.0" encoding="utf-8" ?>
<Feature Scope="Web" Title="Change Content Type Event Handler"
Id="{27C2FDFF-ADA0-4984-955C-6448E182FA88}"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="ListTemplates\ListManifest.xml"/>
<ElementFile Location="Messages\schema.xml"/>
</ElementManifests>
</Feature>
Also, can this be part my solution package WSP for the feature itself so that it gets deployed with the feature?
Thanks in advance
You have two options here. Either you create a custom list template so that you can specify the id of your custom list template in your elements file, or you have to attach your event receiver through code (feature receiver).
The problem with registering an event receiver declaratively is that you can only specify the list template id (effecting all lists based on the specified template), but not a single list name or id.
You can find an example of such a feature receiver in this article: http://www.sharepointdev.net/sharepoint--development-programming/whether-there-is-a-way-to-register-a-custom-event-handler-at-a-special-list-63446.shtml

ContentType DocumentTemplate not found in a List

I have the following Feature:
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="9A3C5D02-A2EB-4725-97F7-CDA6DE319F1B"
Title="My Custom Types"
Scope="Site"
DefaultResourceFile="core"
Hidden="TRUE"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="Elements.xml" />
<ElementFile Location="templates/MeetingMinutes.docx" />
</ElementManifests>
</Feature>
Which contains the following Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Templates" Url="_cts/Meeting Minutes" Path="templates" RootWebOnly="TRUE">
<File Url="MeetingMinutes.docx" Type="Ghostable" />
</Module>
<ContentType
ID="0x01010066DD088A6B8B46BCA775CCD119FBB3E8"
Name="Meeting Minutes"
Group="Custom Content Types"
Version="0">
<FieldRefs />
<DocumentTemplate TargetName="MeetingMinutes.docx"/>
</ContentType>
</Elements>
I then use this ContentType within a custom List Template:
<ContentTypes>
<ContentTypeRef ID="0x0101">
<Folder TargetName="Forms/Document" />
</ContentTypeRef>
<ContentTypeRef ID="0x01010066DD088A6B8B46BCA775CCD119FBB3E8">
<Folder TargetName="Forms/Document" />
</ContentTypeRef>
<ContentTypeRef ID="0x0120" />
</ContentTypes>
I deploy the solution, activate the feature, and create an instance of the List Template. I go into the library and select Settings > Document Library Settings > Content Types: Meeting Minutes > Parent: Meeting Minutes > Advanced settings. I'm now in the Advance Settings of the Site Content Type. The URL of the existing document template is MeetingMinutes.docx and there is an (Edit Template) link which points to http://myserver/sites/testsite/_cts/Meeting%20Minutes/MeetingMinutes.docx. Everything's shiny.
But, I hit the back button two times so I'm back in the settings of the List Content Type. This time when I click Advance settings, the URL of the existing document template is still MeetingMinutes.docx, but there is no (Edit Template) link. Troubling.
Pressing on, I go back to AllItems.aspx and click New > Meeting Minutes. As Word is loading, I see a little Opening dialog which says, Opening: http://myserver/sites/testsite/Shared%20Documents/Forms/Document/MeetingMinutes.docx, to which Word responds: "Word was unable to read this document. It may be corrupt."
So the Document Template works correctly in the Site Content Type (where it does me no good), but is not working in the List Content Type (where I really need it). Now, I know I could put this in _layouts, but from what I've read, _cts is the way to do it. What am I doing wrong?
Rich, I'm not exactly sure what's going on because I created a feature using your feature and elements files as you specified and it works correctly for me.
There is one difference though.
When I create a new document in the library from the content type, the template url is
http://myserver/sites/testsite/Shared%20Documents/Forms/Meeting Minutes/MeetingMinutes.docx
Not
http://myserver/sites/testsite/Shared%20Documents/Forms/Document/MeetingMinutes.docx
Somehow your content type seems to be looking in the wrong folder for the template. I hope that gives you some clues.
I had the same exact problem with document template for List Content Type.
What I did is just what SharePoint do when you create your library from web site : duplicate the document template inside the “Forms” folder of the library in a subfolder that have the same name than the content type.
You just need to add a module element somewhere in your project :
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="MeetingMinutesListInstanceTemplate" Url="Shared Documents/Meeting Minutes" Path="templates" RootWebOnly="TRUE">
<File Url="MeetingMinutes.docx" Type="Ghostable" />
</Module>
</Elements>
It worked for me.

Can't display Sharepoint List view webpart

I have a feature that automatically creates some web part pages. I want to display a list in my web part page but I can't get the list to show up. Here is my code in my element.xml file:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Path="PageTemplates" Url="" >
<File Url="Tab3.aspx" Name="Tab3.aspx" Type="Ghostable" >
<View List="Lists/Links"
BaseViewID="0"
WebPartZoneID="Left"
WebPartOrder="0"/>
</File>
</Module>
</Elements>
I know i set up the page correctly because I put the following content editor web part into the page and it shows up:
<AllUsersWebPart WebPartZoneID="Left" WebPartOrder="0">
<![CDATA[
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"
xmlns:cewp="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
<Title>Some content that you want to provision with the feature</Title>
<FrameType>TitleBarOnly</FrameType>
<cewp:Content>
Hello world.
</cewp:Content>
</WebPart>
]]>
</AllUsersWebPart>
I'm getting the following error in the log: Not enough information to determine a list for module "(null)". Assuming no list for this module.
What am I doing wrong?
More details:
When I use
<View List="Lists/Links"...>
I get no error but nothing shows up on my page. if I enter a bogus list name I get the following error:
Cannot complete this action.
Please try again. at Microsoft.SharePoint.Library.SPRequestInternalClass.EnableModuleFromXml(String bstrFeatureDirectory, String bstrUrl, String bstrXML)
at Microsoft.SharePoint.Library.SPRequest.EnableModuleFromXml(String bstrFeatureDirectory, String bstrUrl, String bstrXML)
I don't believe the previous error I quoted is related to my problem. The error I posted before was
I believe I need to create a ListInstance element in elements.xml file of my feature. I added the following to the top of my file:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance
FeatureId="6A9FB262-8EAD-46C1-814B-7FED72D34EBF"
Id="Links"
Url="Links"
Title="Links"
TemplateType="103"/>
....
I get the following error:
Failed to find a suitable list for tag in module for file 'Tab3.aspx' given List attribute 'Links'.
Where is that list located? You may need to specify the web name, probably by Guid. If 'lists' is the web then once you reference this you only need the list name, i.e. 'links'
My solution was to create the page in Sharepoint Designer and then copy the code into the feature aspx page.

Resources