Solved

New ribbon button not working in production

Posted on 2013-01-24
8
606 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
ID: 38813918
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
ID: 38813928
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
ID: 38813963
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38814020
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
 

Author Comment

by:kasperEH
ID: 38814078
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
ID: 38814083
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
ID: 38814125
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
ID: 38814516
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 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