There is nice article from MS Blog on creating dynamic ribbons in CRM 2011 http://blogs.msdn.com/b/crm/archive/2011/03/30/create-dynamic-ribbon-controls.aspx. I have followed the same approach to create a split button. However, here in my case we want to have the Menu XML dynamically generated based on some entity data. However, there was a problem when we tried to do that using ODATA query. There was nothing wrong in the code. ODATA query was able to retrieve the data and pass the result set to the call back method to populate ribbon split button. However, once the population is done in the code, control is moving back to starting point in the code(function DynamicMenu(CommandProperties)). It’s going into infinite loop.
function DynamicMenu(CommandProperties)
{
getData(CommandProperties, SuccessCallBack, ErrorCallBack);
}
function getData(CommandProperties, SuccessCallBack, ErrorCallBack)
{
//ODATA Stuff
success: function (data, textStatus, XmlHttpRequest)
        {
              // Success Call Back
       SuccessCallBack(CommandProperties,data);
        },
//ODATA Stuff
}
function SuccessCallBack(CommandProperties,data)
{
// Split Button population stuff
}
After bit(I can say a lot of) of struggle I felt it might be due to Asynchronous AJAX call in the script. To verify that I have commented ODATA call and kept “SetTimeOut(method(),4000)” in my code and did populate split button using static MenuXML. It’s again going to infinite loop. This time I have commented  “SetTimeOut” method too. Now, it’s working perfectly.
So, i thought of replacing ODATA Async Call with SOAP Synchronous call. This time it worked like a charm.….!!!!!! J
Hope it helps…!!!!
Cheers
Vikranth Pandiri