I have a problem. I want to add Custom action on a Sharepoint Edit form. This must be FlyoutAnchor and i want generate his content dynamically. I'm adding them throuh ClientContext object model(using C#). This is my code(part omitted):
string format =
@"<CommandUIExtension xmlns=""http://schemas.microsoft.com/sharepoint/"">" +
"<CommandUIDefinitions>" +
"<CommandUIDefinition Location=\"Ribbon.ListForm.Edit.Actions.Controls._children\">" +
"<FlyoutAnchor Id=\"COB.SharePoint.Ribbon.WithPageComponent.PCNotificationGroup.Dropdown\" Sequence=\"10\" " +
" LabelText=\"My layuout\" Alt=\"Sample Flyout\" TemplateAlias=\"o1\" PopulateDynamically=\"true\" PopulateOnlyOnce=\"true\" PopulateQueryCommand=\"COB.PageComponent.Command.PopulateDropDown\" />" +
"</CommandUIDefinition>" +
"</CommandUIDefinitions>" +
"<CommandUIHandlers>" +
"<CommandUIHandler Command=\"Sample.ButtonCommand.Command\" CommandAction=\"javascript:debugger;HelloRibbon(arguments);\" />" +
"<CommandUIHandler Command=\"COB.PageComponent.Command.PopulateDropDown\" CommandAction=\"javascript:PopulateDropDown.apply(this, arguments);\" />" +
"</CommandUIHandlers>" +
"</CommandUIExtension>";
ClientContext context = new ClientContext(TargetUrl);
var site = context.Site;
var populate = site.UserCustomActions.Add();
populate.Title = "PopulateDropDown";
populate.Location = "ScriptLink";
populate.ScriptBlock = // TODO
populate.Update();
context.Load(list, oList => oList.UserCustomActions);
context.ExecuteQuery();
but I don't know what to write in TODO string. For simple button action, I can write
function HelloRibbon(a){alert(a);}
And it will be call. In that article http://www.sharepointnutsandbolts.com/2010/02/ribbon-customizations-dropdown-controls.html i founded sample code, in "2. JavaScript page component" section there is code that generate menu items dynamically. But i don't know how i must adapt this code to ClientContext object model. Thanks for help.
COB.SharePoint.Ribbon.PageComponent.registerClass(\'COB.SharePoint.Ribbon.PageComponent\', CUI.Page.PageComponent);
. What is wrong?