How to use custom dispForm in sharepoint list view? - sharepoint

I am using list view to show the list items in share point 2013. When user clicks the title the custom page should be shown instead of default display page(dispForm.aspx) of share-point.

Define XmlDocuments in contentType:
https://msdn.microsoft.com/en-us/library/office/aa543825.aspx
Example:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Parent ContentType: Workflow Task (0x010801) -->
<ContentType ID="0x010100AF4E4BE6CF8048959C4172F4298CE42A"
Name="MyName"
Group="MyGroup"
Description="MyDescription"
Version="0">
<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">
<New>_layouts/MyFolder/New.aspx</New>
<Display>_layouts/MyFolder/New.aspx</Display>
<Edit>_layouts/MyFolder/Edit.aspx</Edit>
</FormUrls>
</XmlDocument>
</XmlDocuments>
</ContentType>
</Elements>
In code behind you get current item
SPListItem item = SPContext.Current.ListItem;

Related

SharePoint - Ribbon Button showing wrong LabelText

I have a Ribbon Button with the following XML:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Ribbon.Library.Actions.AddAButton"
Location="CommandUI.Ribbon"
RegistrationId="171"
RegistrationType="List"
Title="Change Email Ribbon Button">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.ListForm.Edit.Commit.Controls._children">
<Button Id="Ribbon.ListForm.Edit.Commit.NewRibbonButton"
Command="ChangeEmailButtonCommand"
Image16by16="/_layouts/15/$Resources:core,Language;/images/formatmap16x16.png?rev=23" Image16by16Top="-127" Image16by16Left="-91"
Image32by32="/_layouts/15/$Resources:core,Language;/images/formatmap32x32.png?rev=23" Image32by32Top="-477" Image32by32Left="-307"
LabelText="$Resources:Toolkit,ChangeEmailButtonLabel"
TemplateAlias="o2" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="ChangeEmailButtonCommand"
CommandAction="javascript:
ChangeEmailAction();
" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
<CustomAction Id="Ribbon.ListForm.Edit.Commit.Scripts" Location="ScriptLink" ScriptSrc="/_layouts/15/GOToolkit/JS/loadJsOrCssFile.js?version=1.7.3" />
</Elements>
Now, the LabelText on my button, shows the exact same text, as it does in the XML: "$Resources:Toolkit,ChangeemailButtonLabel", where I'd expect it to show the text that I have defined in the 'ChangeEmailButtonLabel', which looks like this:
<data name="ChangeEmailButtonLabel" xml:space="preserve">
<value>Change email</value>
</data>
Am I missing something here?
Check that your resources file is stored in the SharePoint Resources folder.
Also, don't know if it's a game changer but you can add ";" at the end of your syntax.

ADF Declarative component not being processed?

So as the title says, I made a declarative component but when I add it to a web page it just displays the tag, and not the content
My tag
> <?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<af:componentDef var="attrs" componentVar="component">
<af:goImageLink id="cm" icon="/img/contextmenu.gif" destination=""
rendered="#{attrs.showPopup}">
<af:showPopupBehavior popupId="contextMenu" triggerType="click"
alignId="cm" align="endAfter"/>
</af:goImageLink>
<af:popup id="contextMenu" contentDelivery="immediate" launcherVar="source"
eventContext="self" rendered="#{attrs.showPopup}">
<af:menu binding="#{backingBeanScope.popupProcedimentos.menu}" id="m1"></af:menu>
</af:popup>
<af:popup rendered="#{attrs.showPopup}" id="p1" contentDelivery="immediate"
binding="#{backingBeanScope.popupProcedimentos.popupProcedimento}"
launcherVar="source" eventContext="self">
<af:dialog binding="#{backingBeanScope.popupProcedimentos.dialog}"
stretchChildren="first" id="d1" title="Nova janela"
contentWidth="500" contentHeight="500">
<af:inlineFrame sizing="preferred"
binding="#{backingBeanScope.popupProcedimentos.inlineFrame}"
shortDesc="Nova página" id="iframe"
source="#{backingBeanScope.listaProcessoAdministrativo.procedimentoUrl}#{attrs.DDocName}"></af:inlineFrame>
</af:dialog>
</af:popup>
<af:xmlContent>
<component xmlns="http://xmlns.oracle.com/adf/faces/rich/component">
<display-name>popupProcedimentos</display-name>
<component-extension>
<component-tag-namespace>component</component-tag-namespace>
<component-taglib-uri>/popupproceds</component-taglib-uri>
<attribute>
<attribute-name>showPopup</attribute-name>
<attribute-class>java.lang.Boolean</attribute-class>
<default-value>false</default-value>
</attribute>
<attribute>
<attribute-name>DDocName</attribute-name>
<required>true</required>
<attribute-class>java.lang.String</attribute-class>
</attribute>
</component-extension>
</component>
</af:xmlContent>
</af:componentDef>
</jsp:root>
And i just call it in the other page like this
> <popupproced:popupProcedimentos DDocName="sss" id="popup" showPopup="true" > </popupproced:popupProcedimentos>
But the rendered html page just display the tag like that, any help?
The first line of the declarative component is invalid
"> <?xml version='1.0' encoding='UTF-8'?>"
Frank
I forgot to declare the tag lib in the project of the page I was using to test it. Now everything is working fine.

Custom SharePoint 2010 Documentset contenttype

I'm working on a custom contenttype of the type Documentset.
I want to set the alllowed contenttypes, but this is not working, it's only showing the defeult document. I read several blogs but i can't find my solution.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Parent ContentType: Document Set (0x0120D520) -->
<ContentType ID="0x0120D520008d2ff418027e4c31b54d155b98596748"
Overwrite="True"
Name="Custom Dossier"
Group="Custom group"
Description="Custom dossier"
Inherits="True"
Version="0">
<FieldRefs>
<FieldRef ID="{8D6C094C-3E1F-41f4-BEE3-25B27EE09702}" Name="Dossier_Nummer" DisplayName="Dossiernummer" Required="True" />
</FieldRefs>
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/office/documentsets/allowedcontenttypes">
<act:AllowedContentTypes xmlns:act="http://schemas.microsoft.com/office/documentsets/allowedcontenttypes" LastModified="05/31/2012 08:46:56">
<AllowedContentType id="0x0101" />
<AllowedContentType id="0x0101000490d50c50624b6ca21c637ef39cd89b" />
</act:AllowedContentTypes>
</XmlDocument>
</XmlDocuments>
</ContentType>
</Elements>
You can use ContentType binding element for assigning CTs to document library.
Have you tried adding all the nodes necessary for the document set template? A great example is located here: http://code.msdn.microsoft.com/office/Create-Custom-Document-Set-318393ce/sourcecode?fileId=57420&pathId=1173424883

Add Change Item order ribbon in Sharepoint 2010

I want to add Change item order ribbon into ribbon panel. I have created feature and activated, however i still cant see the item order ribbon. Can anyone help me with this?
below is my code
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!--Change Item order Ribbon-->
<CustomAction
Id="SPChangeItemOrder"
Location="CommandUI.Ribbon.ListItem"
RegistrationId="101"
RegistrationType="List"
Title="List View Ribbon Customization"
>
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.ListItem.Actions.Controls._children">
<!--Get Details from CMDUI.XML-->
<Button
Id="Ribbon.ListItem.Actions.ChangeItemOrder"
Alt="Change the order of the items in this list."
Sequence="20"
Command="ChangeLinkOrder"
LabelText="$Resources:core,cui_ButChangeItemOrder;"
ToolTipTitle="$Resources:core,cui_ButChangeItemOrder;"
ToolTipDescription="$Resources:core,cui_STT_ButChangeItemOrder;"
TemplateAlias="o2"
Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-192" Image16by16Left="-144"
Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-192" Image32by32Left="-288"
/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="ChangeLinkOrder" CommandAction="javascript:alert('Please check Change Item Order');"></CommandUIHandler>
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
Try something like this where RegistrationID is the Type value of a list definition. You don't need the CommandUIHandler if you want to use SharePoint's OOB Change Item Order command.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!--Change Item order Ribbon-->
<CustomAction
Id="XYZ.Webpart.Links.XYZLinksListDefinition.RibbonSortOrderButton"
Location="CommandUI.Ribbon"
RegistrationId="30099"
RegistrationType="List"
Title="List View Ribbon Customization" >
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.ListItem.Actions.Controls._children">
<Button
Id="Ribbon.ListItem.Actions.RibbonSortOrderButton"
Sequence="25"
Command="ChangeLinkOrder"
Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-192" Image16by16Left="-144"
Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-192" Image32by32Left="-288"
LabelText="$Resources:core,cui_ButChangeItemOrder;"
ToolTipTitle="$Resources:core,cui_ButChangeItemOrder;"
ToolTipDescription="$Resources:core,cui_STT_ButChangeItemOrder;"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
</CommandUIExtension>
</CustomAction>
</Elements>
Invalid value for attribute location in customaction element, choose right location value from here http://msdn.microsoft.com/en-us/library/bb802730.aspx

XmlDocuments Element ignored in Content Type?

I have a content type defined in Elements.xml and I want to add an Event Receiver. My Elements.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Parent ContentType: Announcement (0x0104) -->
<ContentType ID="0x0104008a424de98660457481eb7d8ddb5161ee"
Name="News Posting"
Group="News"
Description="$Resources:NewsCTypeDescription"
Inherits="TRUE"
Version="1"
Sealed="TRUE"
>
<FieldRefs>
<FieldRef ID="{7EBC5918-CB79-440A-8DF3-480C6951C4EB}" Name="NewsExcerpt"/>
</FieldRefs>
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
<spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events">
<Receiver>
<Name>ItemAdded</Name>
<Type>ItemAdded</Type>
<Class>MyAssembly.NewsItemEventReceiver</Class>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<SequenceNumber>10000</SequenceNumber>
<Synchronization>Synchronous</Synchronization>
<Data />
<Filter />
</Receiver>
</spe:Receivers>
</XmlDocument>
</XmlDocuments>
</ContentType>
</Elements>
The weird thing is that the Event Receiver never executes. I've checked the Schema with SharePoint Manager 2010, and it seems that the XmlDocuments element is ignored completely?
Here's the content type SchemaXml according to SharePoint Manager:
<?xml version="1.0" encoding="utf-16"?>
<ContentType ID="0x0104008A424DE98660457481EB7D8DDB5161EE" Name="News Posting" Group="News" Description="A News Posting" Sealed="TRUE" Version="1">
<Folder TargetName="_cts/News Posting" />
<Fields>
<Field ID="{c042a256-787d-4a6f-8a8a-cf6ab767f12d}" Name="ContentType" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="ContentType" Group="_Hidden" Type="Computed" DisplayName="Content Type" Sealed="TRUE" Sortable="FALSE" RenderXMLUsingPattern="TRUE" PITarget="MicrosoftWindowsSharePointServices" PIAttribute="ContentTypeID" Customization="">
<FieldRefs>
<FieldRef ID="{03e45e84-1992-4d42-9116-26f756012634}" Name="ContentTypeId" />
</FieldRefs>
<DisplayPattern>
<MapToContentType>
<Column Name="ContentTypeId" />
</MapToContentType>
</DisplayPattern>
</Field>
<Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" Group="_Hidden" Type="Text" DisplayName="Title" Required="TRUE" FromBaseType="TRUE" Customization="" ShowInNewForm="TRUE" ShowInEditForm="TRUE" />
<Field ID="{7662cd2c-f069-4dba-9e35-082cf976e170}" Name="Body" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Body" Group="_Hidden" Type="Note" RichText="TRUE" RichTextMode="FullHtml" IsolateStyles="TRUE" DisplayName="Body" Sortable="FALSE" NumLines="15" Customization="" />
<Field ID="{6a09e75b-8d17-4698-94a8-371eda1af1ac}" Name="Expires" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Expires" Group="_Hidden" Type="DateTime" DisplayName="Expires" Format="DateOnly" Customization="" />
<Field ID="{7EBC5918-CB79-440A-8DF3-480C6951C4EB}" Group="News" Name="NewsExcerpt" DisplayName="Excerpt of the Article" Description="165 Characters maximum" MaxLength="165" Type="Text" Customization="" />
</Field>
</Fields>
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<Display>ListForm</Display>
<Edit>ListForm</Edit>
<New>ListForm</New>
</FormTemplates>
</XmlDocument>
</XmlDocuments>
</ContentType>
I have tried adding a FormTemplates XmlDocument as well, just to see if that works, but even this is ignored (I've changed the ListForm to ListForm2, but the SchemaXml is unchanged.
I've deleted the entire Web Application and Content Database to make sure there was nothing stale/stuck, but the result is still the same.
Is XmlDocuments depreciated in SharePoint 2010? What are the alternatives?
You should add your event receiver as a feature, maybe even as a part of the same feature that installs the content type. We always do it this way and it works perfectly

Resources