I am having difficulty registering a custom user action through JavaScript. I am using the following code example. The code executes without any error however the button fails to appear on the Ribbon. I am hoping someone maybe able to point out where I have gone wrong

var clientContext = SP.ClientContext.get_current();
var oWeb = clientContext.get_web();
var oList = oWeb.get_lists().getByTitle(listTitle);
var userCustomActionColl = oList.get_userCustomActions();

clientContext.load(oList, 'UserCustomActions', 'Title');

var oUserCustomAction = userCustomActionColl.add();
oUserCustomAction.set_title("Related Items -" + fieldDisplayName);
var uiExtension = '<CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">' +
            '<CommandUIDefinitions>' +
                '<CommandUIDefinition Location="Ribbon.ListForm.Edit.Actions.Controls._children">'+
                    '<Button Id="RibbonTest2" '+
                            'Command="TestCommand" '+
                            'Sequence="0" '+
                            'Image16by16="/_layouts/images/NoteBoard_16x16.png" '+
                            'Image32by32="/_layouts/images/NoteBoard_32x32.png" '+
                            'Description="Uses the notification area to display a message." '+
                            'LabelText="Notify hello" '+
                            'TemplateAlias="o1"/>' +
                '<CommandUIHandler Command="TestCommand" '+
                    'CommandAction="javascript:SP.UI.Notify.addNotification(\'Hello from the notification area\');" />'+

  • Please check this and this. Also you can do this with the help of PowerShell as given here. Jul 11, 2019 at 5:13
  • Also there are some examples in Microsoft documentation, here. Jul 11, 2019 at 5:16
  • Thanks Ganesh. What i am actually trying to do is target lists that have a custom field type. I use CSR to render the field (Its a custom picker) and dynamically add the custom actions if they do not exist. I have other custom action being added (List Item Menu), and these work fine. Jul 11, 2019 at 5:55

1 Answer 1


After parking it for a few days i have managed to get it working by removing the following calls:-

  • set_location

  • set_registrationId

  • set_registrationType

  • set_sequence

I have also removed the icon references because they were invalid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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