kasperEH
asked on
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?
ASKER
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}&ListId={ListId}&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>
ASKER
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?
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".
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".
ASKER
I tried to re-create the solution with the production server's site URL but that didn't change anything.
ASKER
The first custom action (the one with registration id 101) was just en experiment, so I have removed it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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)