I have a very basic question about CustomActions in the Elements.xml, I have successfully created a little application that ads an item in the Context Menu for my document libraries for files, my goal is to have this same Custom Action available for Files and for Folders, so far it is only working for Files when I'm using the RegistrationID="0x0101" and for folders "0x0120"
I would like to have my solution properly working for both types.
Here is my Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
ScriptSrc="/_layouts/CustomContextMenu/Permissions.js"
Location="ScriptLink"
Sequence="100">
</CustomAction>
<CustomAction Id="CustomContextMenu.MenuItemClicked"
RegistrationType="ContentType"
RegistrationId="0x0101"
Location="EditControlBlock"
ImageUrl="/_layouts/CustomContextMenu/security-key.png"
Title="External Access"
Description="This options allows you to configure the access to this item for external users">
<UrlAction Url="javascript:PermissionsDialog('{SiteUrl}', '{ItemId}', '{ListId}');" />
</CustomAction>
</Elements>
Location="EditControlBlock"
RegistrationId="101"
RegistrationType="List"
RequireSiteAdministrator = "False"
Rights = "AddListItems"
Description="Custom Upload"
Title="Move To" >
This works for me both folders and files.
Related
'm trying to add a ribbon in my project server site and it's working but I'm currently looking for a way to change my icon
Here the code I use:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="d6e0a4c1-19a9-4846-92fb-d0593aa3bbfc.myAppNewFormAction"
RegistrationType="List"
RegistrationId="115"
Location="CommandUI.Ribbon"
Sequence="10001"
Title="New myApp Form">
<CommandUIExtension>
<!--
Update the UI definitions below with the controls and the command actions
that you want to enable for the custom action.
-->
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Documents.New.Controls._children">
<Button Id="Ribbon.Documents.New.myAppNewFormActionButton"
Alt="New myApp Form"
Sequence="100"
Command="Invoke_myAppNewFormActionButtonRequest"
LabelText="New myApp Form"
TemplateAlias="o1"
Image32by32="Mysite/Pwa/ImageFolders/myAppLogoBug-onwhite-32.png"
Image16by16="Mysite/Pwa/ImageFolders/myAppLogoBug-onwhite-16.png" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="Invoke_myAppNewFormActionButtonRequest"
CommandAction="~appWebUrl/Pages/Default.aspx?Action=New&Source={Source}&ListURLDir={ListUrlDir}"/>
</CommandUIHandlers>
</CommandUIExtension >
</CustomAction>
</Elements>
So on my project server; I created a list in which I stored my image but it's not working, the icon shows me an empty case
I also tried to convert my image in base 64 but the result is the same :/
Any idea of what I'm doing wrong?
My test demo for your reference.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="cfe1a724-53ea-4a66-acda-7bc69c2fff1c.CustomRibbonImage"
RegistrationType="List"
RegistrationId="{$ListId:OOBDoc;}"
Location="CommandUI.Ribbon"
Sequence="10001"
Title="Invoke 'CustomRibbonImage' action">
<CommandUIExtension>
<!--
Update the UI definitions below with the controls and the command actions
that you want to enable for the custom action.
-->
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Documents.New.Controls._children">
<Button Id="Ribbon.Documents.New.CustomRibbonImageButton"
Alt="Request CustomRibbonImage"
Sequence="100"
Command="Invoke_CustomRibbonImageButtonRequest"
LabelText="Request CustomRibbonImage"
TemplateAlias="o1"
Image32by32="~sitecollection/SiteAssets/test.png"
Image16by16="~sitecollection/SiteAssets/test.png" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="Invoke_CustomRibbonImageButtonRequest"
CommandAction="~appWebUrl/Pages/Default.aspx?{StandardTokens}&SPListItemId={SelectedItemId}&SPListId={SelectedListId}"/>
</CommandUIHandlers>
</CommandUIExtension >
</CustomAction>
</Elements>
First off i am a big fat NOOB in regards to Sharepoint 2007 webpart development but i am working at it.
Now for the real problem, so i develop this webpart and follow the 'Loose' advise from various sites on how to setup the features.xml, .xml, manifest.xml, solution.ddf and solution.build files. Basically, i have a all-in-one solution where i build the webpart and then in post-build event compile all the source files into the WSP deployment package.
Problem i am having is that I can add the solution to the sharepoint site but when i go to Deploy it through CA-Operations-Solution management i get this great error:
Error as reported from Sharepoint
Failed to instantiate file "ChartPartWP.webpart" from module "ChartPartWP": Source path "ChartPartWP\ChartPartWP.webpart" not found.
When i looked at the file-system the folder ChartPart is present in TEMPLATE\FEATURES with the ChartPartWP.webpart and other support files.
What is not happening that i need to resolve.
Edit: 10/24/2011 # 11:36PM
Solution.ddf
.OPTION EXPLICIT
.Set CabinetNameTemplate=ChartPartWP.wsp
.Set DiskDirectoryTemplate=CDROM
.Set DiskDirectory1=Package
.Set CompressionType=MSZIP
.Set UniqueFiles="ON"
.Set Cabinet=On
.Set SourceDir="\\<fileserver>\common share\Software_Development\MPT\Sharepoint2007\ChartPart\"
Manifest.xml manifest.xml
; binary
bin\release\TCBOE.ChartPart.dll TCBOE.ChartPart.dll
; feature files
TEMPLATE\FEATURES\ChartPartWP\ChartPartWP.xml ChartPartWP\ChartPartWP.xml
TEMPLATE\FEATURES\ChartPartWP\feature.xml ChartPartWP\Feature.xml
; web part files
TEMPLATE\FEATURES\ChartPartWP\ChartPartWP.webpart ChartPartWP\ChartPartWP.webpart
TEMPLATE\FEATURES\ChartPartWP\LockedChartPartWP.webpart ChartPartWP\LockedChartPartWP.webpart
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/"
SolutionId="{0C32EA7F-78C2-4814-A4C9-88256E49E371}">
<FeatureManifests>
<FeatureManifest Location="ChartPartWP\feature.xml" />
</FeatureManifests>
<Assemblies>
<Assembly Location="TCBOE.ChartPart.dll"
DeploymentTarget="GlobalAssemblyCache" />
</Assemblies>
</Solution>
ChartPartWP.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="ChartPartWP"
List="113" Url="_catalogs/wp"
Path="ChartPartWP"
RootWebOnly="True">
<File Url="ChartPartWP.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="ChartParts" />
</File>
<File Url="LockedChartPartWP.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="ChartParts" />
</File>
</Module>
</Elements>
feature.xml
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="47D62F5E-B0E0-4f93-BCD1-081CA794527C" Version="3.5.1.0"
Title="TCBOE ChartPart"
Description="Provides a Chart Web object to be used in Sharepoint 2007."
AutoActivateInCentralAdmin="TRUE"
Scope="Site">
<ElementManifests>
<ElementManifest Location="ChartPartWP.xml" />
<ElementFile Location="ChartPartWP.webpart" />
<ElementFile Location="LockedChartPartWP.webpart"/>
</ElementManifests>
</Feature>
Would there be any receivers/handlers i need make are implemented for the installation to take hold? I didnt read anything about it but read something about a FeatureReceiver for a purpose, but cant remember for the life-of-it, why you need the FeatureReceiver (SPFeatureReceiver)
SPFeatureDefinition.AutoActivateInCentralAdmin Property
Gets a value that specifies whether the Feature is activated on the central administrative Web site, site collection, or Web application upon installation.
Without testing your entire samples, using this property sounds off to me. Try removing that.
update: you should post your .webpart also (it is a xml).
Try these configs: Feature.xml
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Id="47D62F5E-B0E0-4f93-BCD1-081CA794527C" Version="3.5.1.0" Title="TCBOE ChartPart" Description="Provides a Chart Web object to be used in Sharepoint 2007." Scope="Site">
<ElementManifests>
<ElementManifest Location="ChartPartWP\ChartPartWP.xml" />
<ElementFile Location="ChartPartWP\ChartPartWP.webpart" />
<ElementFile Location="ChartPartWP\LockedChartPartWP.webpart"/>
</ElementManifests>
</Feature>
webpart.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="ChartPartWP" List="113" Url="_catalogs/wp">
<File Path="ChartPartWP.webpart" Url="ChartPartWP.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="ChartParts" />
</File>
<File Path="ChartPartWP.webpart" Url="LockedChartPartWP.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="ChartParts" />
</File>
</Module>
</Elements>
If nothing works, I would recommend installing and using the VSeWSS 1.3 from Microsoft, create a new webpart, hit F5, test it. If you can see it in the "Add Web Parts" dialog, move your files over. This is the closest you will get to the SharePoint 2010 experience (which is terribly improved).
Having to fiddle with these files, even more to a beginner, should not be your burden.
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
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.
I have written a feature(Site scoped) that adds custom menu items to the New Menu and EditControlBlock of a SharePoint 2007 document library. These menu items should show up only when the user has add and edit permissions for that document library. This works great except for one particular case where the user has only read permission for the parent site but has full control over the document library. In this case the menu items under EditControlBlock show up correctly but the menu items under New menu do not show up. I have set the same rights for all the menu items. Below are the sample entries in Feature and Element manifest file
<?xml version="1.0" encoding="utf-8" ?>
<Feature
Id="59bba8e7-0cfc-46e3-9285-4597f8085e76"
Title="My Custom Menus"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="Elements.xml" />
</ElementManifests>
</Feature>
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="EditMenu1" RegistrationType="FileType" RegistrationId="txt" Location="EditControlBlock" Sequence="106" ImageUrl="/_layouts/images/PPT16.GIF" Title="My Edit Menu" Rights="AddListItems,EditListItems">
<UrlAction Url="javascript:var surl='{SiteUrl}'; window.location='/test/mypage.aspx?siteurl='+surl+'&itemurl={ItemUrl}&itemid={ItemId}&listid={ListId}&Source='+window.location" />
</CustomAction>
<CustomAction Id="NewMenu1" GroupId="NewMenu" RegistrationType="List" RegistrationId="101" Location="Microsoft.SharePoint.StandardMenu" Sequence="1002" ImageUrl ="/_layouts/images/DOC32.GIF" Title="My New Menu" Rights="AddListItems,EditListItems">
<UrlAction Url="javascript:var surl='{SiteUrl}'; window.location='/test/mypage.aspx?siteurl='+surl+'&listid={ListId}&Source='+window.location" />
</CustomAction>
</Elements>
Am I missing anything? Please advice.
Regards,
Jagannath
you may need to try and elevate their permissions in the code.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(web.Site.ID))
{
// implementation details omitted
}
});
run with elevated permissions