Solved

New ribbon button not working in production

Posted on 2013-01-24
8
598 Views
Last Modified: 2013-01-24
I have created a solution that adds a new button to the ribbon, it works fine in the test environment where I could deploy it with Visual Studio 2010. I have deployed the solution in the production environment by first adding the solution with SharePoint 2010 Management Shell, then deploying it in Central Administration (had to do that because it was global), and finally activating the feature in the solution. I have also added the button image files. I get no error messages, but the button is not there in the lists (in views, in List Tools) where it is supposed to be. Any ideas?
0
Comment
Question by:kasperEH
  • 5
  • 3
8 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
Comment Utility
Hi,
could you perhaps share the button definition?
Just to verify registration ids,...

Can you test it on a second web app on your test machine?
(just to check if its web app or machine related)
0
 

Author Comment

by:kasperEH
Comment Utility
This is the Like button, you helped me with, so I guess it's OK :-) Anyway, here is the button definition:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
  Location="EditControlBlock"
  RegistrationId="101"
   RegistrationType="List"
  Id="LikeSingleItem"
  Title="Like Single Item"
  Rights="ViewListItems,EditListItems"
  ImageUrl="/_layouts/images/DevLeap.SP2010.UIExtensions/IconArchive.gif"
  Description="Like this item">
    <UrlAction Url="~site/_layouts/DevLeap.SP2010.UIExtensions/DevLeapInvoiceChangeStatus.aspx?ItemId={ItemId}&amp;ListId={ListId}&amp;Status=Archived" />
  </CustomAction>
  <CustomAction
   Id="RibbonAlert"
   RegistrationId="100"
   RegistrationType="List"
   Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListItem.Actions.Controls._children">
          <Button Id="SampleRibbonCommand"
                  Alt="Like"
                  Description="Like button"
                  Sequence="5"
                  Command="LikeDocs"
                  Image16by16="/_layouts/images/Like/Thumbs up_16x16.png"
                  Image32by32="/_layouts/images/Like/Thumbs up_32x32.png"
                  LabelText="Like"
                  TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="LikeDocs"
                          EnabledScript="javascript:
                          
                             function checkDocsSelected()
                             {
                               // Check the number of selected items
                               var items = SP.ListOperation.Selection.getSelectedItems();
                               return (items.length >= 1);
                             }
                             checkDocsSelected();"
                          CommandAction="javascript:
                          
                             // Shared variables
                             var ctx;
                             var itemsToLike;
                             var notifyId = '';

                             // Function that archives the selected items
                             function likeDocs() {
                             
                               // Notify the end user about the work in progress
                               this.notifyId = SP.UI.Notify.addNotification('Liking docs...', true);
                          
                               // Get the current ClientContext
                               this.ctx = new SP.ClientContext.get_current();

                               // Get the current Web
                               var web = this.ctx.get_web();

                               // Get the currently selected list
                               var listId = SP.ListOperation.Selection.getSelectedList();
                               var sourceList = web.get_lists().getById(listId);

                               // Get the selected items and like each of them
                               var items = SP.ListOperation.Selection.getSelectedItems(this.ctx);
                               
                               var item;      
                               this.itemsToLike = new Array(items.length);
                               for(var i in items) {
                                 item = items[i];
                                 
                                 // Get each selected item
                                 var listItem = sourceList.getItemById(item.id);
                                 this.itemsToLike.push(listItem);
                                 this.ctx.load(listItem);
                               }
                               
                               // Effectively load items from SharePoint
                               this.ctx.executeQueryAsync(Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this, onQueryFailed));
                             }
                             
                             // Delegate called when server operation is completed upon success
                             function onQuerySucceeded(sender, args) {
                               // Mark each item as Like
                               var item = null;
                               do {
                                 item = this.itemsToLike.pop();
                                 if (item != null) {
                                   var prevvalue = item.get_item('Like');
                                   if (prevvalue == null)
                                   {
                                        prevvalue = '';
                                   }
                                   if (CheckLike(prevvalue) == false)
                                   {
                                    var newvalue = RibbonLike(prevvalue);
                                    item.set_item('Like', newvalue);
                                    item.update();                                  
                                   }
                                 }
                               } while (item != null);
                               
                               // Effectively update items in SharePoint
                               this.ctx.executeQueryAsync(Function.createDelegate(this, onUpdateSucceeded), Function.createDelegate(this, onQueryFailed));
                             }

                             // Delegate called when server operation is completed upon success
                             function onUpdateSucceeded(sender, args) {
                               SP.UI.Notify.removeNotification(this.notifyId);
                               SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
                             }
                             
                             // Delegate called when server operation is completed with errors
                             function onQueryFailed(sender, args) {
                               alert('The requested operation failed: ' + args.toString());
                             }

                             likeDocs();" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>

Open in new window

0
 

Author Comment

by:kasperEH
Comment Utility
One thing I've been thinking about is: In Visual Studio in the Site URL for the solution I wrote the URL for the test environment, deployed and tested it. Then I changed it to the URL for the production and rebuilt, but the WSP didn't seem to be updated. The file still has the same date. Could that be part of the problem?
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
Comment Utility
Hi,
normally not. The url is just used when you click "Deploy" as it then add / readd the solution, run the deploy and feature activation (if not configured differently).

To re-create the solution you can run "Rebuild" and "Package".
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:kasperEH
Comment Utility
I tried to re-create the solution with the production server's site URL but that didn't change anything.
0
 

Author Comment

by:kasperEH
Comment Utility
The first custom action (the one with registration id 101) was just en experiment, so I have removed it.
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
Comment Utility
Did you change the "Solution Configuration" from "Debug" to "Release"?
Perhaps you are looking the the wrong path.

I assume your solution do not only contain the feature for the new button but also some other files / features?
Is the solution deployed for the first time?

I have just tested: the custom action definition works as expected (OK, I am missing the pics and ...) but at least on my custom lists the button shows up.

If there is nothing else in there which is already used, I would try to:
- Deactivate all activated features of the solution (through Site Settings)
- Retract the solution (through Central Admin)
- Wait until finished
- Remove solution (through Central Admin)

Then I would Rebuild, re-package the WSP file. Then make a copy, change extension to ".cab" and review the content, if the above element is in there.
Then add the solution through SharePoint management shell, deploy it through Central Admin and activate the feature.

HTH
Rainer
0
 

Author Closing Comment

by:kasperEH
Comment Utility
When I went through your list, I found out that the feature wasn't activated in Site Settings even though I had issued an stsadm command to activate it, but apparently that wasn't enough. Thanks a lot, Rainer.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now