Monday, February 27, 2012

Replacing a Button on the Server Ribbon in Sharepoint

in the MSDN article Walkthrough: Replacing a Button on the Server Ribbon

it is not as straight forward as it used to be. i can not complete it with only copy and paste the code into visual studio 2010 , then compile and deploy it to the SharePoint Server. I can't see the custom ribbon button since i use the incorrect registrationID.

first you will need to find the specific RegistrationID for Template Type that you want to custom Ribbon Tool Bar. from this link: SharePoint 2010: RegistrationId List Template Type IDs you can get the registrationID.

here is my sample code to test a button replaced with the default button.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="Ribbon.Library.Actions.ReplacementButton"
    Location="CommandUI.Ribbon"  RegistrationId="115"
    RegistrationType="List"
    Title="Replace a Ribbon Button">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
          Location="Ribbon.Library.Actions.ConnectToClient">
          <Button Id="Ribbon.Library.Actions.ConnectToClient.ReplaceNewButton"
            Command="ReplacementButtonCommand"
            Image16by16="/_Layouts/MyFeature/NEWITEM.GIF"
            Image32by32="/_LayoutsMyFeature/NEWITEM.GIF"
            LabelText="Replaced Button"
            TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <!--<CommandUIHandlers>
        <CommandUIHandler
          Command="ReplacementButtonCommand"
          CommandAction="javascript:alert('This button has been replaced with the new One.');" />
      </CommandUIHandlers>-->
      <CommandUIHandlers>
        <CommandUIHandler
          Command="ReplacementButtonCommand"
          CommandAction="javascript:viewDialog('http://win-vq9f73d6i7j:28888/_layouts/FormServer.aspx?XsnLocation=http://win-vq9f73d6i7j:28888/RecyleItem/Forms/template.xsn&amp;SaveLocation=http%3A%2F%2Fwin%2Dvq9f73d6i7j%3A28888%2FRecyleItem&amp;ClientInstalled=true&amp;Source=http%3A%2F%2Fwin%2Dvq9f73d6i7j%3A28888%2FRecyleItem%2FForms%2FAllItems%2Easpx&amp;DefaultItemOpen=1')" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
  <CustomAction Id="Ribbon.Library.Actions.NewButton.Script"
    Location="ScriptLink"
    ScriptBlock="function viewDialog(linkUrl) { 
                  var options = {   
                      url: linkUrl,   
                      width: 800,   
                      height: 600, 
                  }; 
                  SP.UI.ModalDialog.showModalDialog(options);
              }"></CustomAction>
</Elements>


Please note that JavaScript can not recognize the & and i must replace it with "&amp;" otherwise
you will get the following errors

"Error    1    Entity 'DefaultItemOpen' not defined.    c:\users\administrator\documents\visual studio 2010\Projects\ReplaceARibbonButton\ReplaceARibbonButton\ReplaceARibbonButton\Elements.xml    27    357    ReplaceARibbonButton"

Error    2    Expecting ';'.    c:\users\administrator\documents\visual studio 2010\Projects\ReplaceARibbonButton\ReplaceARibbonButton\ReplaceARibbonButton\Elements.xml    27    372    ReplaceARibbonButton

Tuesday, February 21, 2012

How to configure an External Item Picker with BCS datasource

How to: Embed an External Item Picker Control in an InfoPath Form

i am doing an experience based on the above MSDN article. though the article
had a dedicate table to explain each fields that need to be filled in the External
Item Picker Properties window. I spent a bit of time to figure out those fields
mapping with BCS residing in the sharpeoint Server. i had attached the picture
to show how they should match.. I hope this post can help to quickly setup
the External Item Picker Control in the InfoPath form

  • Fill the ECT Namespace (External Item Picker Field) field with Namespace (External Content Type Field).
  • Fill the ECT Name (External Item Picker Field) field with Name (External Content Type Field).
  • Fill the System Instance Name (External Item Picker Field) with External System (External Content Type Field).



External Item Pikcer Properties Window



External Content Type Information Page (In Sharepoint Central Admin Page)