0

Ive done some dev work with sharepoint last year but nothing like what im building today so Im not very experienced with it. I am trying to add a custom button to the ribbon in a list modeled on the contacts template. I wrote the code for the button and tested it in a custom list. For some reason it isnt showing up in the Contacts list i need it to. everything works just fine in a custom list. Heres my code;

<CustomAction

    Id="CsvExportButton"
    RegistrationId="100"
    RegistrationType="List"
    Location="CommandUI.Ribbon"
    Sequence="20"
    Title="Export to CSV">

    <CommandUIExtension>
        <CommandUIDefinitions>
            <CommandUIDefinition Location="Ribbon.ListItem.New.Controls._children">
                            <Button
                                Id="SS7.Ribbon.Customizations.Tab.Actions.Controls.ExportCSV"
                                Alt="Export selected items to CSV"
                                Sequence="20"
                                Command="CMDAlertRibbonButton"
                                LabelText="Export to CSV"
                                Image16by16="/_layouts/1033/images/formatmap16x16.png"
                                Image32by32="/_layouts/1033/images/formatmap32x32.png"
                                TemplateAlias="o1"/>
            </CommandUIDefinition>
        </CommandUIDefinitions>
        <CommandUIHandlers>
            <CommandUIHandler
            Command="CMDAlertRibbonButton"
            CommandAction="javascript:
            function resultCallback(result, value)
            {
            SP.UI.Notify.addNotification('Success!');
            SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
            }

            var ctx = SP.ClientContext.get_current();
            var items = SP.ListOperation.Selection.getSelectedItems(ctx);
            var myItems = '';
            var i;

            for (i in items)
            {
            myItems += '|' + items[i].id;
            }

            if(myItems != '')
            {
            var options = {
            url: '{SiteUrl}/_layouts/MyPage.aspx?Items=' + myItems + '&amp;ListId={SelectedListId}&amp;Source={Source}',
            title: 'My Page',
            allowMaximize: false,
            showClose: true,
            width: 600,
            height: 600,
            dialogReturnValueCallback: resultCallback };

            SP.UI.ModalDialog.showModalDialog(options);
            }" />
        </CommandUIHandlers>


    </CommandUIExtension>

1 Answer 1

0

RegistrationId="100" this is for generic list

you should try

RegistrationId="105" which is for Contacts

you can get the list of registration id over here:

http://sharepointwings.blogspot.in/2012/06/sharepoint-2010-list-template-type.html

2
  • Awesome list!!! I actually solved it yesterday but changing RegistrationType="ContentType" and RegistrationId="0x0106" Commented Oct 19, 2012 at 8:46
  • Your answer is more robust. Just to elaborate my solution, I changed the RegistrationType to "ContentType" to look for Content Type lists and "0x0106" is the RegistrationId for any Contacts based content type list. I found the ID by going to the site collection root>Site Settings>Site Content Types>Contacts and in the URL, the RegistrationId was in the string next to ctype=0x0106. Just another way of doing it I suppose. Im new to Sharepoint dev so I dont know which way is preferred. Commented Oct 19, 2012 at 8:54

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.