Dynamics CRM 2011: CommandProperties CrmParameter not set correctly when passed to FlyoutAnchor JavaScript function

StackOverflow https://stackoverflow.com/questions/9325718

سؤال

I'm trying to create three dynamically filled FlyoutAnchor Ribbon buttons, based on the following SO answer: Add Dropdown Menu to CRM 2011 ribbon

All three FlyoutAnchor buttons use the same PopulateQueryCommand. The JavaScript function which is linked to the command (see code block below) gets the CommandProperties CrmParameter passed as the first argument to be able identify the flyout button which was clicked (and should be filled with dynamically added dropdown menu items).

function DynamicMenu(CommandProperties) {
    /// <summary>Dynamically generate menu items based on context</summary>
    /// <param name="CommandProperties">
    ///    Command properties crm parameter sent from the ribbon.  object used to inject the Menu XML
    /// </param>

    debugger;

    var menuXml = '<Menu Id=\"Sample.DynamicMenu\">' +
                       // ... Other menu XML stuff goes here
                  '</Menu>';

    CommandProperties.PopulationXML = menuXml;  // error here...PopulationXML is undefined... :-(

    // ...
}

The function gets nicely called and the 'CommandProperties' argument is passed (it isn't null and not undefined), but when I try to set the PopulationXML I get an error, because this property is undefined. The other three expected properties listed below are also undefined:

  • SourceControlId: The Id value of the Ribbon control that initiated the event.
  • CommandValueId: A string that is sent with the command event when a button is clicked.
  • MenuItemId: A reference from a control to the Id of a menu item.

When I pass in a second different CrmParameter, for example PrimaryEntityTypeName, this argument is correctly filled / set.

What could be the cause of the messed-up CommandProperties argument?

Update 21-2-2012: To be complete, I also tried the single button approach, such as described in Add Dropdown Menu to CRM 2011 ribbon, but that gave me the same result (no usable Commandproperties object). My CRM server is running Rollup 6, maybe that has something to do with it? Is there a different way of getting this kind of flyout ribbon menu's? Maybe something in pure JavaScript? It should also work in the Outlook CRM Client...

هل كانت مفيدة؟

المحلول

I was facing the same issue, the resolution is instead of using '<Menu Id=\"Sample.DynamicMenu\">', use '<Menu Id="Sample.DynamicMenu">' the difference is of not using escape character for "

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top