FlyOutAnchor buttons are disabled when they refer to multiple JS functions - dynamics-crm

I created a static FlyOut control with multiple buttons. On click of those buttons different JS should fire. I created Commanddefinition for every JS function and made a refernce to them inside buttons controls. But, my buttons become disabled. If all of the buttons refer to the same commanddefinition/ js function, works fine. What am I missing? Any help will be greatly appreciated.
Here's my code:
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="Add_Dynamic_Menu"
Location="Mscrm.Form.new_test.MainTab.Workflow.Controls._children">
<CommandUIDefinition>
<FlyoutAnchor Id="Sample.new_test.form.FlyoutAnchor.Static" Sequence="10"
Command="Mscrm.Enabled"
Image16by16="/_imgs/placeholders/ribbon_placeholder_16.png"
Image32by32="/_imgs/ribbon/newrecord32.png" LabelText="Sample Flyout"
Alt="Sample Flyout" TemplateAlias="isv">
<Menu Id="Sample.new_test.form.Menu">
<MenuSection Id="Sample.new_test.form.MenuSection"
Title="Menu Section Title" Sequence="15">
<Controls Id="Sample.new_test.form.MenuSection.Controls">
<Button Id="Sample.new_test.form.Controls.Button.FirstButton"
Command="Sample.FirstButtonComand" LabelText="First Button"
ToolTipTitle="First Button"
ToolTipDescription="The first button" TemplateAlias="isv"
Sequence="20"/>
<Button Id="Sample.new_test.form.Controls.Button.SecondButton"
Command="Sample.SecondButtonCommand" LabelText="Second Button"
ToolTipTitle="Second Button"
ToolTipDescription="The Second button" TemplateAlias="isv"
Sequence="20"/>
</Controls>
</MenuSection>
</Menu>
</FlyoutAnchor>
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"/>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="Sample.FirstButtonCommand">
<EnableRules>
<EnableRule Id="Mscrm.Enabled"/>
</EnableRules>
<DisplayRules/>
<Actions>
<JavaScriptFunction FunctionName="testfirstbutton"
Library="$webresource:new_testfirstbutton"> </JavaScriptFunction>
</Actions>
</CommandDefinition>
<CommandDefinition Id="Sample.SecondButtonCommand">
<EnableRules/>
<DisplayRules/>
<Actions>
<JavaScriptFunction FunctionName="testsecondbutton"
Library="$webresource:new_testsecondbutton"> </JavaScriptFunction>
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules/>
<DisplayRules/>
<EnableRules/>
</RuleDefinitions>
<LocLabels/>
</RibbonDiffXml>

What you are doing looks fine, so double check the webresource names and everything.
An approach to troubleshoot
1) Switch everything to the webresource/function that works
2) Add the other function to the JavaScript webresource and see if it still works (if it fails, then it was the javascript function(s)).
3) Switch one of the FunctionName's to the second function while keeping the websresource all the same.

A couple of minor things I noticed. Both of your buttons have the same sequence number. I would change firstbutton to 10. Second, you do not have the Mscrm.Enabled rule on the seconnd buttons command def.
These ribbons love to be finicky.

Related

GridLayout not showing on devices

I've this problem using GridLayout, tested on two Samsung devices.
This is an excerpt from the layout:
<GridLayout
a:layout_width="0dp"
a:layout_weight="2"
a:layout_height="match_parent"
a:rowCount="5"
a:columnCount="4">
<TextView
a:id="#+id/tvDescentsFemaleCount"
style="#style/dataPanelControlLabels"
a:layout_width="0dp"
a:layout_row="0"
a:layout_column="0"
a:layout_columnWeight="3"
a:layout_columnSpan="3"
a:text="#string/pnlVisitDescentsFemaleDescentNumber" />
<Button
a:id="#+id/bDescentsFemaleCount"
style="#style/dataButton"
a:layout_width="0dp"
a:layout_row="1"
a:layout_column="0"
a:layout_columnWeight="3"
a:layout_columnSpan="3"
a:layout_marginLeft="3dp"
a:layout_marginRight="3dp" />
<ImageView
a:id="#+id/ivDescentsMoveLeft"
a:layout_width="0dp"
a:layout_row="1"
a:layout_column="3"
a:layout_columnWeight="1"
a:src="#drawable/freccia_indietro"
a:adjustViewBounds="true"
a:scaleType="centerInside" />
<TextView
a:id="#+id/tvDescentsMaleCount"
style="#style/dataPanelControlLabels"
a:layout_width="0dp"
a:layout_row="2"
a:layout_column="0"
a:layout_columnSpan="3"
a:layout_columnWeight="3"
a:text="#string/pnlVisitDescentsMaleDescentNumber" />
<Button
a:id="#+id/bDescentsMaleCount"
style="#style/dataButton"
a:layout_width="0dp"
a:layout_row="3"
a:layout_column="0"
a:layout_columnSpan="3"
a:layout_columnWeight="3"
a:layout_marginLeft="3dp"
a:layout_marginRight="3dp" />
<ImageView
a:id="#+id/ivDescentsMoveRight"
a:layout_width="0dp"
a:layout_row="3"
a:layout_column="3"
a:layout_columnWeight="1"
a:src="#drawable/freccia_avanti"
a:adjustViewBounds="true"
a:scaleType="centerInside" />
<ImageView
a:id="#+id/ivDescentsAdd"
a:layout_width="0dp"
a:layout_row="4"
a:layout_column="0"
a:layout_columnWeight="1"
a:layout_margin="3dp"
a:src="#drawable/add"
a:adjustViewBounds="true"
a:scaleType="centerInside"
a:padding="6dp" />
<ImageView
a:id="#+id/ivDescentsRemove"
a:layout_width="0dp"
a:layout_height="wrap_content"
a:layout_columnWeight="1"
a:layout_row="4"
a:layout_column="1"
a:layout_margin="3dp"
a:padding="6dp"
a:src="#drawable/meno"
a:adjustViewBounds="true"
a:scaleType="centerInside" />
<ToggleButton
a:id="#+id/tbDescentsFemaleSelect"
style="#style/toggleButtonPv"
a:layout_width="0dp"
a:layout_row="4"
a:layout_column="2"
a:layout_columnWeight="1"
a:layout_height="wrap_content"
a:layout_margin="3dp"
a:textOn="#string/pnlVisitDescentsFemaleShort"
a:textOff="#string/pnlVisitDescentsFemaleShort"
a:padding="4dp" />
<ToggleButton
a:id="#+id/tbDescentsMaleSelect"
style="#style/toggleButtonPv"
a:layout_width="0dp"
a:layout_row="4"
a:layout_column="3"
a:layout_columnWeight="1"
a:layout_height="wrap_content"
a:layout_margin="3dp"
a:textOn="#string/pnlVisitDescentsMaleShort"
a:textOff="#string/pnlVisitDescentsMaleShort"
a:padding="4dp" />
</GridLayout>
On the complete layout there is another GridLayout, where the only difference is the absence of the a:layout_columnSpan attribute (I've shortened the classic namespace declaration from xmlns:android... to xlmns:a...).
This is the less-significant screenshot from my PC designer :
This is the screenshot from an SM-T535, API level 21 Samsung tablet :
On the upper left corner there is a GridLayout, on the middle right there is an android.support.v7.widget.GridLayout. I've left the layout limits only to show how the widgets are rendered.
This is the screenshot from an SM-T585, API level 24 Samsung tablet:
The GridLayout is rendered correctly, whereas the android.support.v7.widget.GridLayout on the right is rendered almost in the same way.
This is the screenshot from the same SM-T585, where all the two widgets are the standard GridLayout:
Please note also the switch bank under the GridLayout on the right; they are android.support.v7.widget.SwitchCompat, because originally I was porting the app on a GT-N800 Samsung tablet, and the standard Switch widget was not so customizable. In the Activity code I'm substituting the standard typeface with a font from an asset. Only on the SM-T585 the font is shown correctly.
The activity inherits from Activity, but inheriting from AppCompatActivity doesn't change a single pixel.
The entire project is a Xamarin app (I'm porting the same app developed for IOS, so I've to recycle a great part of the code), and the IDE is VS2017 Community edition.
The same layout (GridLayout widgets) works correctly on a Nexus 7, although the screen is too small.
Any suggestion appreciated.
Thanks.
Rodolfo.

Adding a button to account entity homepage's ribbon/command bar

Playing with the ribbon, I tried to add a button over the account entity homepage's ribbon/command bar, just before the +New button. But it is not showing anywhere over the page. What am I missing?
This is the sample XML I've coded after reading the SDK.
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="Bee.CustomAction.GoToUrl" Location="Mscrm.HomepageGrid.account.MainTab.Management.Controls._children">
<CommandUIDefinition>
<Button Id="Bee.HomepageGrid.account.GoToUrl" Command="Bee.CommandDefinition.GoToUrl" LabelText="Go To URL" ToolTipDescription="Description, Go to URL with selected account" ToolTipTitle="Title, Go to URL with selected account" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="Bee.CommandDefinition.GoToUrl">
<EnableRules>
<EnableRule Id="Bee.EnableRule.SelectionCountOne" />
</EnableRules>
<DisplayRules>
<DisplayRule Id="Bee.DisplayRule.AllClients"/>
</DisplayRules>
<Actions>
<Url Address="http://localhost/mysite" PassParams="true"></Url>
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules>
<DisplayRule Id="Bee.DisplayRule.AllClients">
<CommandClientTypeRule Type="Modern" />
<CommandClientTypeRule Type="Refresh" />
<CommandClientTypeRule Type="Legacy" />
</DisplayRule>
</DisplayRules>
<EnableRules>
<EnableRule Id="Bee.EnableRule.SelectionCountOne">
<SelectionCountRule Minimum="1" Maximum="1" AppliesTo="SelectedEntity" />
</EnableRule>
</EnableRules>
</RuleDefinitions>
<LocLabels />
</RibbonDiffXml>
I just apply one CommandClientTypeRule Type="Refresh", it works. Again apply all three types not working. All have different meanings as below.
Modern: The command bar is presented using Microsoft Dynamics CRM for tablets.
Refresh: The command bar is presented using the updated user interface.
Legacy: The ribbon is presented in forms for entities that were not updated or in a list view in Microsoft Dynamics CRM for Microsoft Office Outlook.
<DisplayRules>
<DisplayRule Id="Bee.DisplayRule.AllClients">
<CommandClientTypeRule Type="Refresh" />
</DisplayRule>
</DisplayRules>
But Go to url button goes to overflow section means in the drop down hidden menu.
Displaying the button on command bar before NEW button apply some sequence, following is RibbonXml that show the button just before NEW button, when one record is selected.
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="Bee.CustomAction.GoToUrl" Location="Mscrm.HomepageGrid.account.MainTab.Management.Controls._children" Sequence="5">
<CommandUIDefinition>
<Button Id="Bee.HomepageGrid.account.GoToUrl"
LabelText="Go To URL"
ToolTipDescription="Description, Go to URL with selected account"
ToolTipTitle="Title, Go to URL with selected account"
Alt="Go to"
Command="Bee.CommandDefinition.GoToUrl"
Sequence="5"
TemplateAlias="o1" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="Bee.CommandDefinition.GoToUrl">
<EnableRules>
<EnableRule Id="Bee.EnableRule.SelectionCountOne" />
</EnableRules>
<DisplayRules>
<DisplayRule Id="Bee.DisplayRule.AllClients"/>
</DisplayRules>
<Actions>
<Url Address="http://localhost/mysite" PassParams="true"></Url>
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules>
<DisplayRule Id="Bee.DisplayRule.AllClients">
<CommandClientTypeRule Type="Refresh" />
</DisplayRule>
</DisplayRules>
<EnableRules>
<EnableRule Id="Bee.EnableRule.SelectionCountOne">
<SelectionCountRule Minimum="1" Maximum="1" AppliesTo="SelectedEntity" />
</EnableRule>
</EnableRules>
</RuleDefinitions>
<LocLabels/>
</RibbonDiffXml>
I would suggest you to try Ribbon Workbench. You don't need to download/extract/modify/pack/import anymore. Everything is done directly from Dynamics CRM and without any knowledge of XML.
You should add LocLabels to your RibbonDiffXml. Attribute LabelText a.o. must hold references to these localized labels. They are not meant to hold the texts themselves.
Look on CodePlex for some fine ribbon editors; they will give you a good start!

How to set a number of error with xul like firebug does

As the question explains itself i've a button like firebug and i wanted to set there a number when some events happens like firebug doeas when it detects errors on the page.
Does anyone know how to set it?
This is the code of the top button that displays a panel, so i want to set there a number when certains events happens..
<panel id="asv-panel">
<hbox align="start">
<vbox>
<hbox align="center" style="background-color:#ffffff">
<image id="asvbutton-panel-icon" width="200px" height="50px" style="margin-left:10px"/>
</hbox>
<hbox style="background-color:#fff" id="menuPanelContainer">
<html:div style="margin-top:20px;margin-left:20px;width:150px" id="menuLogginInicial">
<description value="&asbutton.Signin;"/>
<html:hr/>
<image id="asvbutton-logoface" width="50px" height="50px" style="cursor:pointer" onclick="asvbutton.login();"/>
<image id="asvbutton-logogoogle" width="47px" height="45px" style="align:left;cursor:pointer"/>
<image id="asvbutton-logotwitter" width="50px" height="50px" style="align:left;cursor:pointer"/>
</html:div>
</hbox>
</vbox>
</hbox>
</panel>
</toolbarbutton>
After thousands of pages and samples... the easiest way was creating a div and doing an appendChild to it (old school method) :D
Hope this helps someone.

zk can't access method in included .zul

When I try the below code (as is suggested here by Ryan Wu for question):
<?page title="Auto Generated index.zul"?>
<window title="Hello World 2!!" border="none" width="600px">
<include id="inc" src="/zk/wind.zul" mode="instant" />
<button label="do it" onClick="inc$wind.doModal()" />
</window>
After pressing the button I am getting this error:
inc$wind.doModal();'' : Attempt to resolve method: doModal() on undefined variable or class name
The file wind.zul looks as
<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<window id="wind" title="new page title" border="normal" visible="false" width="300px">
New Content Here!
</window>
</zk>
Can someone let me know what is wrong? Thanks...
According to http://books.zkoss.org/wiki/ZK%20Developer%27s%20Reference/UI%20Composing/ID%20Space
I need:
1. use 'Path'
2. add some ID for main window (f.i. id="w0")
and write in index.zul something similar ( file wind.zul not changed)
<?page title="Auto Generated index.zul"?>
<window id="w0" title="Hello World 2!!" border="none" width="600px">
<include id="inc" src="/zk/wind.zul" mode="instant" />
<button label="do it" onClick='Path.getComponent("/w0/inc/wind").doModal()' />
</window>
Thanks for me own :))

Adding a custom button to the advanced find robbon

I've got my customizations.xml importing ok, but when I open the Advanced Find Dialog, it tell me "Ribbon XML Validation Error":
I can't seem to get any more info than that. Below is my customizations.xml text, I've tried to simplify it as much as possible.
<ImportExportXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Entities></Entities>
<Roles></Roles>
<Workflows></Workflows>
<FieldSecurityProfiles></FieldSecurityProfiles>
<Templates />
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="DEW.Mscrm.AdvancedFind.Groups.Debug.UploadFetchXml"
Location="Mscrm.AdvancedFind.Groups.Debug._children" >
<CommandUIDefinition>
<Button Id="DEW.Mscrm.AdvancedFind.Groups.Debug.UploadFetchXmlButton" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules />
<EnableRules />
</RuleDefinitions>
<LocLabels />
</RibbonDiffXml>
<EntityMaps />
<EntityRelationships />
<OrganizationSettings />
<optionsets />
<Languages>
<Language>1033</Language>
</Languages>
</ImportExportXml>
For others looking to find the solution, or at least something to take note of if you're having a similar problem.
My problem was that the id for the different elements were the same. You must have unique id's even among different elements. And "Mscrm.AdvancedFind.Groups.Debug._children" should have been "Mscrm.AdvancedFind.Groups.Debug.Controls._children"

Resources