0

I'm trying to create a custom button on the Ribbon which appears in the Ribbon.EditingTools.CPInsert section when the user is editing content in a wiki page or content area. I'm using the OfficeDev PnP example code, specifically the Core.RibbonCommands sample which uses a remote provisioning pattern via CSOM to create the CustomUIAction. I've modified the code a little bit to alter the type of button that is created. When I run the code my button gets created. I am able to see it when I go to Page -> Edit -> Insert. Unfortunately the button always appears disabled. If I remove the command attribute of the button, it lights up, but of course is quite useless since it doesn't fire anything.

Note: I'm able to add custom action buttons in an almost identical way to content types (i.e. document) list views and it all works.

Here is an example of the XML which is the basis of the Custom UI Actions:

    <CustomAction Id="afe72475-035c-437a-abec-c177ff7bba07.AddVideoCustomAction"
                            Description="Add broadcast center content"
                            Location="CommandUI.Ribbon"
                            Sequence="20000"

                         >
    <CommandUIExtension>
        <!-- 
        Update the UI definitions below with the controls and the command actions
        that you want to enable for the custom action.
        -->
        <CommandUIDefinitions>
            <CommandUIDefinition
                Location="Ribbon.EditingTools.CPInsert.Groups._children">
                <Group
                    Id="UploadLinkRibbonActionGroup"
                    Sequence="80"
                    Description="This group will contain the Button control"
                    Title="MG"
                    Template="Ribbon.Templates.Flexible2">
                    <Controls Id="UploadLinkControl">
                        <Button
                                    Id="MG.AddVideoCustomActionButton"
                                    ToolTipTitle="Video"
                                    ToolTipDescription="Insert a video onto the page."
                                    Sequence="10"
                                    Command="Invoke_MGV"
                                    LabelText="Request AddVideoCustomAction"
                                    TemplateAlias="o1"
                                    Image32by32="_layouts/15/images/placeholder32x32.png"
                                    Image16by16="_layouts/15/images/placeholder16x16.png"

                                    />
                    </Controls>
                </Group>
            </CommandUIDefinition>
            <CommandUIDefinition
                 Location="Ribbon.EditingTools.CPInsert.Scaling._children">
                <MaxSize
                    Id="CustomEditRibbonActionsOneMaxSize"
                    Sequence="15"
                    GroupId="UploadLinkRibbonActionGroup"
                    Size="LargeLarge"/>
            </CommandUIDefinition>
        </CommandUIDefinitions>
        <CommandUIHandlers>
            <CommandUIHandler Command="Invoke_MGV"
                                                CommandAction="javascript:alert('test');"
                                                 EnabledScript="javascript:function JustReturnTrue()
                                                    {
                                                                return true;
                                                    }
                                                    JustReturnTrue();">

            </CommandUIHandler>
        </CommandUIHandlers>
    </CommandUIExtension >
</CustomAction>
0

Holy heck, never mind. The issue appears to be my browser cache. I was using chrome and I needed to just clear out the entire cache (Menu -> Clear Browsing Data) and it seemed to work fine after.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.