Ribbon button value rule depending on statecode value - dynamics-crm-2011

I added a new custom button to quote form ribbon. This button should only appear, if the statecode is active (Value: 1).
I created following CommandDefinition:
<CommandDefinition Id="mySolution.quote.Form.MyButton.Command">
<EnableRules />
<DisplayRules>
<DisplayRule Id="mySolution.QuoteIsActive" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="myFunction" Library="$webresource:new_myLibrary" />
</Actions>
</CommandDefinition>
And following DisplayRule:
<DisplayRule Id="mySolution.QuoteIsActive">
<ValueRule Field="statecode" Value="1" Default="true" />
</DisplayRule>
But if I use this DisplayRule my button never appears. If I remove the rule from CommandDefinition the button is always visible.
I also tried to use 'Active' as value (as shown at the bottom of this post, with the same result.
What is the trick to define a rule depending on statecode? Or did I miss something?

Try using Status text values ("Open", "Draft", "Active", ect.) instead of number values. I have a similar case with Status Reasons. Hope it will help!

I couldn't find anything to verify this, but display rules seem to have issues in the command bar. I had better luck using enable rules, and those actually act like you would expect display rules to act in the command bar. In other words, if a button in the command bar is disabled then it's not displayed. You can read about it in the MSDN documentation.

I think your problem here is that your EnableRules is empty.
However, are you doing that modifications by hand?
If so, use CRM 2011 Visual Ribbon Editor, this tool will do almost all job for you.

I think that your problem is that Statecode should be 0, not 1. Do a sql query on statecode and statecodename (use FilteredView).

Just add simple .js script for updating ribbon. Ribbon updates only on page load. Thats why your button became always unvisible. Here is code sample:
function refreshRibbonOnChange()
{
Xrm.Page.ui.refreshRibbon();
}
Then add web resource and attach it to button click. Simple!

Related

How to implement PXFormulaCombo or Formula Builder control?

As per title. I need to customise AM207500 - Configuration Maintenance screen to add another custom field that will allow me to enter formula similar to QtyRequired field.
I got as far as displaying the correct dialog. But its missing the fields selection.
I believe I'm missing the OnRootFieldsNeeded property. But every time I try to edit the ASPX and manually add this. Its being cleared by Acumatica.
Am I in the right direction ? And how do I force this property in my ASPX ?
TIA
A bit unconventional, but have you tried updating the ASPX page on the custom pages and then clicking on the files section to update the file? This will then ensure the file update occurs before publish and hold the configuration

How to validate CheckBox in Kentico 8.2?

I am working in Kentico 8.2, and I want the user to have to accept all of the terms and conditions. For this, I am using a check box. If that check box is unchecked then user will not be able to submit the form.
This is not achievable through Kentico help which says that I can achieve it by making the check box multiple choice. I have done this and it works but I want the check box's own validation to work.
I cannot attach a picture here otherwise I would show you guys what I have done so far.
If anyone has a solution then please help.
Do you use the basic Kentico forms module?
You can use Validation on a field.
in the Forms module:
new field "conditions"
check "Required"
default value unchecked
Validation "Add validation rule"
select General condition
Enter text > press edit and in the code tab add the following macro:
{%conditions.Value == 1%}
add an error message
dont forget to press Apply and save the field
This worked in my sample.

CRM 2011 Sub-Grid: Call JavaScript On-Click or On-Focus

How can JavaScript execute when a sub-grid receives focus?
I have a sub-grid that shows all Cases associated with an Account.
I would like to disable some fields on the form when the sub-grid receives focus.
RibbonDiffXML action for a ribbon button:
<Actions>
<JavaScriptFunction Library="$webresource:mda_convertemailtocaselib" FunctionName="ConvertEmailToCaseLib.addToCase">
<CrmParameter Value="SelectedControlSelectedItemIds" />
</JavaScriptFunction>
</Actions>
This passes the sub-grid select items to a ribbon button, but I would like the JavaScript to execute before the ribbon button is pressed.
I haven't tried either of these out, but hopefully one of them should work for you.
Although it is a subgrid, there still is a control on the form. Unfortunately there is no "supported" way to know when a control gets focus since there aren't any OnFocus/OnBlur methods exposed via the CRM JS API. However you should be able to add your own JS event handler for that control and disabled the fields via the API Xrm.Page.getControl("fieldname").setDisabled(true)
I'm not 100% sure if this way would work, but it would be pretty sweet. Create a CustomRule EnableRule. In this CustomRule you call your own JS. In this create a function where you disable the fields and then return true to make the button enabled. It would look something like this:
function disableFieldsEnableRule() {
Xrm.Page.getControl().setDisabled(true);
...
...
return true; // so the button is enabled
}
The only reason I'm not sure if this will work is because I'm not sure if the Enable rules are checked each time you click on the subgrid or just the first time (I think it should be every time). Also I'm not sure if you want those fields re-enabled once you click off. If you do you might have to do something similar to this with a button on the native form, or something else.

CRM 2011 Homepage Grid Ribbon enable rule doesn't work

I have a custom button in Activity homepage grid ribbon. I have an enable rule that calls a Javascript function. This rule doesn't seem to be working - it's not calling the Javascript function, I've put an alert to verify this. When I test my javascript function by calling from a Form OnLoad, everything looks fine.
So i'm guessing that the Homepage ribbon is not loading the js library somehow ? Has anyone come across this before ?
Please help.
<EnableRule Id="RRM.activitypointer.HomepageGrid.RunReport">
<CustomRule Library="RRM_/Script/Common/Main.js" FuncionName="RRM.Common.enableRunReport"></CustomRule>
</EnableRule>
I've found the solution.
A couple of things
1. The way the webresource is called. Changing the rule to something like below worked
<CustomRule Library="$webresource:RRM_/Script/Common/Main.js" .. >
2. Loading the dependent webresources (since this button is not on a form). Adding dummy custom rules to call the dependent webresources fixed it
<CustomRule Library="$webresource:name" Functionname="isNAN"/>
You have a typo, is FunctionName instead of FuncionName
<EnableRule Id="RRM.activitypointer.HomepageGrid.RunReport">
<CustomRule Library="$webresource:name" Functionname="isNAN"/>
<CustomRule Library="RRM_/Script/Common/Main.js" Functionname="RRM.Common.enableRunReport"></CustomRule>
</EnableRule>

Phantom Keytip conflict in Microsoft Office 2010 Ribbon Custom UI

I'm trying to create a custom ribbon in one of my Excel 2010 addins, and for some reason Office is overriding some of the keytips (keyboard accelerators). I know if Office sees a conflict it will usually override one or both of the keytips to "Y", "Y2", "Y3", etc.. but in this example I only have one button in my tab so there is no other control for it to conflict with.
Here is the XML:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab id="tabid_1" label="SampleTab" keytip = "B">
<group id="grpid_1" label="SampleGroup">
<button id="btnid_1" label="SampleButton" keytip="Z" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Instead of the SampleButton having a keytip of Z, it gets replaced with "Y2".
I see this behavior regardless of the keytip of the Tab (which is currently "B").
I checked to make sure that there wasn't some other button with a keytip of "BZ" that might be conflicting, but didn't see any.
I also see that behavior if I try to make the keytip of the SampleButton be "Y", but I assume this is because all "Y*" keytips are reserved for conflicts.
Incidentally, I was also having this problem with a keytip of "C", but for some un-explained reason that was happening only when I didn't have a label for the <group>. As soon as I added a label to the <group>, "C" stopped being overridden with "Y2". Very strange behavior.
Anyone have any ideas what could be causing this?
Thanks in advance!
I was having the same issue and I ended up just changing the keytip value from an uppercase "Z" to a lowercase "z" and it worked. No idea why. Hopefully it works for you.
This is the standard behaviour for custom (as opposed to builtin) tabs in an office application.
To test this yourself simply add a couple of custom tabs through the UI.
next hit the ALT key and notice how all of the custom tabs are Y1, Y2, Y3, accelerators..
However as noted by the OP, this shouldn't be the behaviour when setting the keytip property programmatically or through XML for the addin's ribbon UI elements.
Since it only happens with a limited subset of key combos I'd imagine it could be a bug. Recommend logging this on the microsoft connect website.
Sorry but the accepted answer didn't work for me!
In my VSTO solution I empirically found a working ALT-Shortcut is "G".
So in my C# code I set:
Globals.Ribbons.GetRibbon<MyRibbon>().tabMyRibbonTab.KeyTip = "GGG";
I use three G's to minimize conflicts with other Add-Ins.
This worked for me and I could even select the RibbonTab in Excel 2007 by using SendKeys (see this other question).
Regards, Jörg

Resources