Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 637
  • Last Modified:

New ribbon button not working in production

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
kasperEH
Asked:
kasperEH
  • 5
  • 3
1 Solution
 
Rainer JeschorCommented:
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
 
kasperEHAuthor Commented:
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
 
kasperEHAuthor Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Rainer JeschorCommented:
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
 
kasperEHAuthor Commented:
I tried to re-create the solution with the production server's site URL but that didn't change anything.
0
 
kasperEHAuthor Commented:
The first custom action (the one with registration id 101) was just en experiment, so I have removed it.
0
 
Rainer JeschorCommented:
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
 
kasperEHAuthor Commented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now