Custom button on custom tab is always disabled (ribbon bar) - sharepoint

I found a lot of examples how to add custom tab with custom controls on the ribbon bar. But no one works for me. I got the custom tab, but button is always disabled.
There is my current version of code:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="CustomRibbonTab"
Location="CommandUI.Ribbon"
RegistrationId="101"
RegistrationType="List">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Tabs._children">
<Tab
Id="Ribbon.CustomTab"
Title="Custom Tab"
Description="Custom Tab !!!"
Sequence="701">
<Scaling
Id="Ribbon.CustomTab.Scaling">
<MaxSize
Id="Ribbon.CustomTab.MaxSize"
GroupId="Ribbon.CustomTab.CustomGroup"
Size="OneLargeTwoMedium"/>
<Scale
Id="Ribbon.CustomTab.Scaling.CustomTabScaling"
GroupId="Ribbon.CustomTab.CustomGroup"
Size="OneLargeTwoMedium" />
</Scaling>
<Groups Id="Ribbon.CustomTab.Groups">
<Group
Id="Ribbon.CustomTab.CustomGroup"
Description="Custom Group!"
Title="Custom Group"
Sequence="62"
Template="Ribbon.Templates.CustomTemplate">
<Controls Id="Ribbon.CustomTab.CustomGroup.Controls">
<Button
Id="Ribbon.CustomTab.CustomGroup.CustomButton"
Command="CustomTab.CustomButtonCommand"
Sequence="115"
Description=""
LabelText="Custom Button"
Image32by32="/_layouts/images/PPEOPLE.GIF"
TemplateAlias="cust1"/>
</Controls>
</Group>
</Groups>
</Tab>
</CommandUIDefinition>
<CommandUIDefinition Location="Ribbon.Templates._children">
<GroupTemplate Id="Ribbon.Templates.CustomTemplate">
<Layout
Title="OneLargeTwoMedium"
LayoutTitle="OneLargeTwoMedium">
<Section Alignment="Top" Type="OneRow">
<Row>
<ControlRef DisplayMode="Large" TemplateAlias="cust1" />
</Row>
</Section>
</Layout>
</GroupTemplate>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="CustomTab.CustomButtonCommand"
CommandAction="javascript:alert('Hello, world!');"
EnabledScript="javascript:return true;"/>
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
I cleaned up the cache. I read about importance of EnabledScripts attribute in the CommandUIHandler. But I always have the same result:
Did anybody have the same issue? Please help!

I checked out a local custom action of mine, and the EnabledScript followed a different pattern:
EnabledScript="javascript:function JustReturnTrue()
{
return true
}
JustReturnTrue();"
If your item is showing up, but always disabled, I bet that's where the problem is.
I think the attribute is optional anyway, if I recall.

I had the same problem, I'm not sure if this is the proper solution, I'm a newbie. I removed the element from feature which scope was set to "Site", added another feature, set the scope to "Web", added my button item in this feature, saved, deployed, enabled the new feature from site features and it worked.

Related

How to create reusable Components in .NET MAUI?

I have just recently started using .Net MAUI. But now I'm wondering how to use a piece of code, e.g. a self-made navigation bar on all my pages, because it doesn't make sense to write the same code on all 10 pages. I like to know if there is a way to create a component that can be reused like in React or Angular?
PS: This question is not specific to a navigation bar but to the general reuse of code in .NET MAUI.
I have so far watched various videos & articles on this topic, however, it is more about custom controls and did not help me. Most articles corresponded to what was conveyed in this video. I also came across this article, but it didn't help me either.
Thanks for your help :)
First, you can create a new .xaml file named Name.xaml. You can write some codes in it.
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CusComponents.Name">
<ContentView.Content>
<StackLayout Padding="10">
<Label Text="Name" FontAttributes="Bold" />
<Label Text="First name" />
<Entry x:Name="FirstName" Placeholder="First name" />
<Label Text="Last name" />
<Entry x:Name="LastName" Placeholder="Last name" />
</StackLayout>
</ContentView.Content>
</ContentView>
Second, you can use it in the page you want like this. You need to add an xmlns reference to the top of the XML file– this is like a using statement in a C# file. Using the namespace structure for the sample project, this will be xmlns:custom_components="clr-namespace:CusComponents".
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:custom_components="clr-namespace:CusComponents"
x:Class="CusComponents.MainPage">
<custom_components:Name />
</ContentPage>
Here is the view of the code:

SPOnline: After including feature/asset deployment to my SPfx WebPart I can't put it on any SitePage

I'm trying to add some provisioning function to my SPfx WebPart Project on SharePoint Online. The Problem is that as soon as I put the feature information to my package-solution.json the configured lists deploy properly but I can't add the WebPart itself on a Sitepage.
I'm working with Visual Studio Code on a SPfx WebPart Project for SharePoint Online. I already deployed a variety of WebParts an Extensions within our Companys' tenant but I'm pretty new to the thing with features and assets.
My WebPart needs two specific lists which it should deploy by itself when added to the site contents per [New] -> [App].
Therefore I added an elements.xml and two schema-*.xml files to my project and modified the package-solution.json to include them as a feature.
Since then the Lists a deployed properly to the SiteCollection or SubSite where I add the App.
BUT(!) the WebPart itself doesn't show up when editing a SitePage and adding WebParts. Its not even in the popup where you select the WebPart you want.
There are no Install Errors when adding the App too the SiteCollection and the WebPart works well when the feature information is deleted from the package-solution.json.
And here I am, having no clue what's wrong and needing your help.
package-solution.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "sp-bookingtool-admin",
"id": "30d57d62-8319-4b29-b0f9-***********",
"version": "2.0.0.6",
"features": [
{
"title": "sp-bookingtool-admin-features",
"description": "asset-deployment-webpart-client-side-solution",
"id": "523fe887-ced5-4036-b564-***********",
"version": "2.0.0.6",
"assets": {
"elementManifests": [
"elements.xml"
],
"elementFiles": [
"schema-sessions.xml",
"schema-courses.xml"
]
}
}
]
},
"paths": {
"zippedPackage": "solution/sp-bookingtool-admin.sppkg"
}
}
elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance
CustomSchema="schema-sessions.xml"
FeatureId="00bfea71-de22-43b2-a848-***********"
Title="BookingTool-Sessions"
Description="BookingTool-Sessions"
TemplateType="100"
Url="Lists/BookingToolSessions">
</ListInstance>
<ListInstance
CustomSchema="schema-courses.xml"
FeatureId="00bfea71-de22-43b2-a848-***********"
Title="BookingTool-Courses"
Description="BookingTool-Courses"
TemplateType="100"
Url="Lists/BookingToolCourses">
</ListInstance>
</Elements>
1 of two schema.xml
<List xmlns:ows="Microsoft SharePoint" Title="BookingTool-Courses" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/BookingToolCourses" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<Fields>
<Field ID="{1e513910-8092-45f7-b996-***********}" Name="Text_1" Type="Text" DisplayName="Text_1" Group="" Required="TRUE"/>
<Field ID="{d82721d4-0b3c-48cf-9a24-***********}" Name="Text_2" Type="Text" DisplayName="Text_2" Group="" Required="TRUE"/>
</Fields>
<Views>
<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
<RowLimit Paged="TRUE">30</RowLimit>
<Toolbar Type="Standard" />
<ViewFields>
<FieldRef Name="LinkTitle"></FieldRef>
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="LinkTitle" />
</OrderBy>
</Query>
</View>
</Views>
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
</MetaData>
</List>
Thanks to a collegue I found the error by myself.
Against my expectation the "FeatureID" in the ListInstances is NOT a GUID of the developed feature BUT the ID of the Listtemplate you use depending of the "TemplateType".
<ListInstance
CustomSchema="schema-sessions.xml"
FeatureId="00bfea71-de22-43b2-a848-c05709900100"
Title="BookingTool-Sessions"
Description="BookingTool-Sessions"
TemplateType="100"
Url="Lists/BookingToolSessions">
</ListInstance>
00bfea71-de22-43b2-a848-c05709900100 is the ID for Custom Lists and
100 is the Templatetype for that List.

Change Sharepoint Icon in a new ribbon

'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 &apos;CustomRibbonImage&apos; 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>

Excel Custom RibbonUI; Add Section Title for Menu

Im running 2016 Standalone Excel (32bit version). I've been building a custom ribbon and so far so good. The documentation is pretty fluid and well written. However, I cant find any way to include menu 'section titles' as seen below:
Specifically referencing section titles like in the picture (i.e., 'Cell size', 'Visibility' etc). I've seen other Add-Ins emulate this, unless they are COM Add-Ins. Here is the documentation I reference: https://msdn.microsoft.com/en-us/library/dd911038(v=office.12).aspx
Is it out of date? I've tried adding 'Menu with Title' to my project but that doesn't even work. I've also tried adding <labelControl /> , and the ribbon doesn't even load when the labelControl is within a Menu.
Additionally, my version of Excel won't even display a <dialogBoxLauncher> so I'm concerned some things just aren't compatabile with my Excel version to begin with. I'm following the documentation easily and everything else has worked just fine. I even have a editBox in the ribbon I use and don't run into any 91 errors with it. So I know it's not me.
Can anyone duplicate this with the provided API? My ribbon is structured with XML, so I've reduced as much error potential as possible, is that my problem? Should there be run-time code implemented specifically for section titles?
Short snippet of my setup
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnRibbonLoad">
<ribbon>
<tabs>
<tab idMso="TabHome">
<group id="GroupTextTools" insertAfterMso="GroupFont" label="Text Tools">
<gallery id="textcase_gallery" label="Case Select" columns="1" size="large" imageMso="WordArtInsertDialogClassic" onAction="TextCase_SwitchCase" >
<item id="textcase_CapsButton" imageMso="TextAllCaps" label="Uppercase" screentip="Changes selected cells to all uppercase" />
<item id="textcase_ProperButton" label="Propercase" imageMso="ChangeCaseDialogClassic" screentip="Changes selected cells to proper case" />
<item id="textcase_LowerButton" label="Lowercase" imageMso="FontSizeDecrease" screentip="Changes selected cells to all small case" />
</gallery>
</group>
</tab>
<tab id="CustomTab" label="*removed*" insertAfterMso= "TabDeveloper">
<!--
GROUP A
-->
<group id="GroupFileOptions" label="File Options">
<button id="fileoptions_CloseButton" label="Close && Reopen" onAction="RunMacro" imageMso="SourceControlCheckIn" size="large" screentip="Saves Document, Closes && Reopens immediately"/>
<menu id="exportingmenu" label="Exporting" imageMso="FileCheckOut" size="large" screentip="Exporting Options">
<menu id="exportmenu_AsRange" label="As Range"> <!-- This is where I would like section Titles to be instead of another menu -->
<button id="exportmenu_range_CSVCButton" label="To CSV w/commas"/>
<button id="exportmenu_range_CSVSButton" label="To CSV w/spaces"/>
<button id="exportmenu_range_PDF" label="To PDF"/>
</menu>
<menu id="exportmenu_AsSheet" label="As Sheet"> <!--Goal is for this to be a section title, where I tried putting a <labelControl> -->
</menu>
</menu>
</group>
<!-- .... -->
</tab>
</tabs>
</ribbon>
</customUI>
After some trial and error, and an involuntary push from David Zemens by troubleshooting my errors, I've found that by cross referencing all the things I've tried with their Parent Elements, the only one that makes logical compiling sense is a <menuSeparator>, which just so happens to have a 'title' attribute. So by setting that you get a beautiful section title as shown:
<menuSeparator id="someID" title="Test title"/>
I managed to put a menu title only on a dynamicMenu via the getContent callback, which means the xml is defined in VBA as a piece of xml string, not in the customUI xml.
Most comprehensive documentation that I found so far on customUI interfaces is on https://msdn.microsoft.com/en-us/library/dd911038(v=office.12).aspx, however the references are pointing only to 2007. This link contains a much more extensive list of controls and options with extra controls for Access as well http://www.accessribbon.de/en/?Access_-_Ribbons:Ribbon_XML___Controls

EntityRule in subgrid on custom entity not working

I tried to add a button to connection subgrid ribbon. This button should only be visible if the primary entity equals 'new_visitreport'.
Here is my try:
<CustomAction Id="Visitreports.connection.customAction"
Location="Mscrm.SubGrid.connection.MainTab.Management.Controls._children"
Sequence="15" >
<CommandUIDefinition>
<Button Id="Mscrm.SubGrid.connection.AddXYZ"
ToolTipTitle="$LocLabels:Button.AddXYZ.Label"
ToolTipDescription="$LocLabels:Button.AddXYZ.Tooltip"
LabelText="$LocLabels:Button.AddXYZ.Label"
Command="Button.AddXYZ.Command"
Image16by16="$webresource:new_XYZ_16"
Image32by32="$webresource:new_XYZ_32"
TemplateAlias="o1" />
</CommandUIDefinition>
</CustomAction>
<CommandDefinition Id="Button.AddXYZ.Command">
<EnableRules></EnableRules>
<DisplayRules>
<DisplayRule Id="EntityEqualsVisitreport" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="openDialog"
Library="$webresource:new_script_open_dialog">
<StringParameter Value="3EEE3AE1-5543-433E-8123-6A14EA925A96" />
<StringParameter Value="3EEE3AE1-5543-433E-8123-6A14EA925A96" />
<BoolParameter Value="false" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
<DisplayRule Id="EntityEqualsVisitreport">
<EntityRule AppliesTo="PrimaryEntity"
EntityName="new_visitreport" />
</DisplayRule>
It seems that this rule always returns false. If I remove the display rule from command definition the button is visible, but independet of the currently primary entity.
Is there any mistake in my examply or is it not working for custom entitis although it is supported? (MSDN article)
Try using FormEntityContextRule it looks like these guys had the same issue you had. Forum Link
<FormEntityContextRule EntityName="account"/>

Resources