Developer Tip ‘o the Day: Ribbons and Web Resources

You can customize the CRM 2011 Ribbon to add additional functionality via buttons, for example.

When you add such a button, you use Web Resources to identify things such as icons and JavaScript functions, like this:

$webresource:new_CloneRecord.js

$webresource:new_CloneRecord32x32

It important to remember that any Web Resources referenced by the Ribbon exist ( added to CRM and published ) before you import your customized Ribbon XML.

If not, then you’ll receive an exception and the import will fail.

The exception will probably look something like this:

Exception: FaultException`1
Message: The ribbon item ‘MitchMilam.Form.account.MainTab.Save.CloneRecord’ is dependent on Web resource id=’new_CloneRecord32x322′.
StackTrace:
Server stack trace:
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request)
   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request)
   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Execute(OrganizationRequest request)
   at VisualRibbonEditor.ServiceWrapper.ExecuteAsync(OrganizationRequest request, Action`1 callback)
   at VisualRibbonEditor.Solution.<>c__DisplayClassa.<Save>b__6(Object sender, DoWorkEventArgs e)

Leave a Reply 1 comment