Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer
    
Awesome list!!! I actually solved it yesterday but changing RegistrationType="ContentType" and RegistrationId="0x0106" –  Brian Morrison II Oct 19 '12 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. –  Brian Morrison II Oct 19 '12 at 8:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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