Thursday, November 01, 2012

Microsoft Designer 2013 RTM Available

After the release of SharePoint 2013 RTM on MSDN Subscriptions, Microsoft have launched the SharePoint Designer for 2013.

This tool will help you manage the content and look and feel of your SharePoint sites.

Here the main link for this tool:
SharePoint Designer 2013 Site
sharepointdesigner_32bit.exe 282.2 MB
sharepointdesigner_64bit.exe 324.1 MB

Enjoy this new experience of SharePoint 2013 and the new features associated and I recommend a look in the Microsoft SharePoint Designer Team Blog Site for a first overview of the new Features for SharePoint Designer 2013.


Tuesday, July 17, 2012

Office 2013 Preview release Today

Hi all,

As you already know Microsoft launched the "Office 2013 Preview" in this package is also included the SharePoint 2013.
http://www.microsoft.com/en-us/news/

Everybody is very excited with the new SharePoint 2013 will be, Layouts, features, applications, IT Infrastructure, Client Object Model, etc, etc.
Will be very interresting time and also a back to school to learn this new Features, belive me....

Documentation about SharePoint 2013
http://www.microsoft.com/en-us/download/search.aspx?q=sharepoint%202013

Nice collection of links from Jeremy Thake and Joel Oleson
http://wss.made4the.net/default.aspx
http://www.sharepointjoel.com/default.aspx

Have fun and don't burns your head trying playing day and night with the new SharePoint 2013 and being the first one creating articles about the new SharePoint. First, learn about the new Version tool and then surprise yourself with the oportunities you find in the future in the final release :) .

Kind regards,

Wednesday, July 11, 2012

Manage Visibility in List Fields Forms

This article try to help and give some hint or ideas about a topic that normally is asked by users, the ability to manage the visibility of fields in the different Form Lists.
Some users ask the Site owners if it is possible to manage the Field in the different Forms, Display some fields in the new form, other fields in the Edit Form and the same for the Display Form.

The normal answer for this request from the consultant is use the  DataView from SharePoint Designer "Customization Skills in Pages", or Powershell Script "IT Administrator" or use JavaScript code "JavaScript Skills with Webparts in the Forms Lists" to hide columns.
JS Example:

<script language="javascript" type="text/javascript">
      _spBodyOnLoadFunctionNames.push("HideControl");
      function HideControl() {
          var field = document.getElementById('ID control from New Form, Edit Form, Display Form');
          field.parentNode.parentNode.parentNode.style.display = "none";
      }
</script>


To response this request, yesterday evening was playing around with SharePoint 2010 and create a new Application Page to manage the visibility of field in the Form Lists (New Form, Edit Form, Display Form).

PS: Please remember this example project was made to explore some properties in the List and how we can manage, use by your own risk. I belive there is others applications made for SharePoint 2010 that have the same behavior and my project was made in 30 minutes "I spent more time writing this article that creating the application :)) "....

The solution was created using the following tools:
  • Visual Studio 2010
  • SharePoint 2010
  • SharePoint Manager 2010 v2 (Thanks for this tool Carsten Keutmann, every SharePoint Admin or Developer should have...)


SharePoint Deployment:
  • Farm Solution 
  • ManageListPages.wsp
  • Powershell scripts
    • Add-SPSolution -LiteralPath <SolutionPath>
    • Install-SPSolution -Identity <SolutionName> -WebApplication <URLname> -GACDeployment

Feature:
  • Manage List Forms
    • Scope: Web
  • Element File 
    • A new option will appear in the Ribbon (Lists, Document Library, Calendar) Tab "List > Settings > Columns visibility in form" 
    • Rights: "ManageLists" - SPBasePermissions
  • Application Page
    • This page will be Manage the field in the List Forms.

SharePoint Solution: 


Using the API Objects with SharePoint Manager we can access the Field associated to a List and view his properties and validate if they are visible or not, as shown in the image below.



Conditions 
  • If properties (ShowInDisplayForm,  ShowInEditForm,  ShowInNewForm) are null the fields are visible in the Forms.


How to Activate Feature "Manage List Fields Forms"
Site Actions > Site Settings > Manage site features > Manage List Fields Forms > Activate Option



When you access a List View and select the Ribbon Tab "Columns visibility in Form" this Button option will redirect to Application Page where you can manage the Visibility of the Field for the List Forms.



When we access the Application Page, we are able to see the existing status of the Fields and select the Field to manage.


This application will give option to manage the following Forms "New Form, Edit Form, Display Form".



Button "Save Field", this option will save the visibility of the field in the List Forms and display the status in the main board status.
For this example i selected the field "% Complete" and uncheck "Edit Form" to don't display in the Edit Mode.


After make this change you can access you List Forms and validate if the field are correct.
For this example open "New Item" and validate the state of the field "% Complete" is visible.


If you open the Edit option Form the field "% Complete" will not appear, as shown in the image below.


If you open the Display option Form the field "% Complete" will appear again, as shown in the image below.


If you wan to revert to old state of the field, you need to access the "Manage Form Page" and select the correct Field "% Complete" the option "Reset Field to all Forms" and change the status of that field to null.
The value null means that will be accessible to all Forms.

After the selection of this option the field will be displayed in all Forms.


Conclusion:
I understand this is not very complex project and this can be easily be managed in the List properties, but want to show a example on how we can create some BackOffice page to manage your lists properties, in this case manage the fields, but can also be made to create/Manage other properties or create new one like  Propertie Bag, etc...

This Project example is located in the following Link.

Hope you like :)

Kind regards,
André Lage

Tuesday, May 29, 2012

Provisioning Themes to Site Collections and Sub Sites


Provisioning Themes to Site and his sub-sites have been a very request subject by users and i saw a lot of people talking about this subject with the SharePoint Features you should use like “Features”, “Elements”, "Stapling" and "WebProvisioned Handler", but I never saw Real World examples where i can redirect to a site to help them create the feature, that is the reason why I created this example.

Introduction
This solution will add and activate a Custom Theme when a Site Collection associated to a Template is created (in this Case Standard Collection Sites STS#0,…)  and will inherit the Custom Theme every time a Sub site is created.
Create the Theme with PowerPoint
The first thing we need to do is create our Site Theme, one recommended way to create your Theme is using PowerPoint or using “Theme Builder” https://connect.microsoft.com/themebuilder
If you choose Powerpoint you can use one of the Theme that came out of the box using in the Ribbon option “Design > All Themes” there you can make the changes for your requirements.
After you make the changes you can select the option “save Current Theme” and save the file as “CustomTheme.Thmx”.
The file created will be used in our SharePoint Solution to add and activate the Custom Theme when a Site Collection or Sub Site is created.
Create SharePoint Solution to Provision the Theme
The solution will be created using the
  1. Visual Studio 2010
  2. SharePoint 2010
Will be created the following Features:
  1. Stapling STS Template
  1. Scope: WebApplication
  1. FeatureSiteTemplateAssociation (Id of “Provision Site Theme”)
  1. Provision Site Theme
  1. Scope: Site
  1. Feature (FeatureActivated)
  1. Provision Web Theme
  1. Scope: Web
  1. Event Handler (WebProvisioned)
SharePoint Solution
The SharePoint Solution will have 3 Features that will create dependency between them in a way to change the Theme in all process of a new Site Collection or Sub Site without actions of a Site Owner or Site Administrator.
Provision Stapling to Site Template
This Provision Action will add a custom Feature in each Site template, this action will give flexibility to change with the necessary actions and change the Theme to our custom Theme when a Site collection is created.
Create a New Feature, Right Click on Features Folder and select “Add Feature” and select the Scope “WebApplication”.
To add a custom Feature to the Site Template needs to add  Element.xml File where you configure the tag “FeatureSiteTemplateAssociation” and Template Name “STS#0, STS#1, STS#2” where will be the stapling and will be activated when a Site Collection is created.
Provision Site Theme
Create a New Feature, Right Click on Features Folder and select “Add Feature” and select the Scope “Site”.
This Feature will add the Theme file to the Root Site Folder, publish the new Theme and activate the provisioning Web Feature of the Sub Site using Event Receiver.
 Create a new Element.xml file and add the Theme CustomTheme.Thmx using a Module Tag.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="ModuleMyTheme" Url="_catalogs/theme">
    <File Path="NewTheme\CustomTheme.thmx" Url="CustomTheme.thmx" />
  </Module>
</Elements>
This Tag will be use add and manage Files from the SharePoint Solution to be added in the SharePoint Sites and all themes files are stored in the Path “_catalog/theme”, you can view all Themes file using SharePoint Designer.
PS: Needs to be reference the parameter “ElementFile” in the File “CustomTheme.thmx”
and Activate Web Feature:
web.Features.Add(new Guid("1a14b521-aa1d-4f2e-bc23-df127e6e45bb"),true);
web.Update();

Provision Site Web
Create a New Feature, Right Click on Features Folder and select “Add Feature” and select the Scope “web”.
This Feature will inherit the Theme from the parent Site and activate the provisioning of the Sub Site. The provision of the Sub Site is made by Event receiver.
When we select the Event Handler we need to define what type of event we will use, since we want to change the Sub Site when is created we need to add Event in the SharePoint Object SPWeb.
This Event need to be executed after the Sub Site is created “A Site was provisioned” to change the Theme and add the next Event hander for the next Sub Site.
After we add to Visual Studio the Event Handler the properties are define to be global and deployed every time that needs to be call.
After we access to the Web Feature, the Event Hander “ApplyTheme” needs to be associated the Feature “Provision Web Theme” to be activated when a Sub site is created.
After the Event hander is added, need to define the actions associated to this Event,
The Actions will be apply the Theme to the Web,
And Activate the Web Feature “Provision Site Web”, when a sub Site is created the Event Handler for the Web Provisioning associated to the Site is created and the Theme is changed and this will replicate for all new Sub Sites Created.
You can use the SharePoint Manager to view the “Eventreceiver” created in the Object SPWeb, this Event will change the Theme and provision the same change for the Sub Sites.
After the 3 Feature are created you are prepare to Deploy as SharePoint Farm Solution and make the test.
Deploy and Activate Features
To Deploy a SharePoint Solution , you can use the Visual Studio Deployment option, Right Click on Provision Theme and select “Deploy”.
You can use PowerSheel commands to deploy this solution in the SharePoint Farm.
//Add solution to SharePoint Farm
Add-SPSolution -LiteralPath <SolutionPath>
Install-SPSolution -Identity <SolutionName> -WebApplication <URLname> -GACDeployment
To activate the Provision of the Theme in the Site Collection and SubWeb needs to access to SharePoint 2010 Central Administration > Manage Web Application > Select Web Application > Manage Features, there you need to activate Feature “Stapling STS Template”.



After the Feature “Stapling STS Template” is activated we can create a new site Collection to assume the new Theme Solution:
SharePoint 2010 Central Administration > Application Management > Create Site collections
After the Site Collections is created the SharePoint Site should appear with the new theme as expected.
You can validate the Custom Theme was changed accessing to “Site Actions > Site Settings > Site Theme”  and view the CustomTheme as selected in the Solution as expected.
To validate if the Site Collection Feature was activated need to access “Site Actions > Site Settings > Site Actions > Manage site features” and view “Provision Site Theme”.
If you access to “Site Actions > Site Settings > Site collections features” the Feature Provision Web Them will be Activated
After you validate The Root Page, you can create a sub Site and view if the Sub site have the Same Provisioning Handler and change Theme like the Root Site.
After the Sub Site is created, needs to wait some seconds to finish the provisioning and refresh the page to assume the changes in the Sub site.
Project Example
Reference Links:
Feature Stapling
SPWebEventReceiver Methods

PS: These last months a lot of good things are happening to me and that are taking me all time and can't make a lot more SharePoint articles, but the reasons are good and now I am just waiting to came to my arms : ).

Hope you like this article,
Andre Lage

Tuesday, February 21, 2012

Add global Link using Delegate Control

This article will give a simple example "or remember" on how you can use the Delegate controls to change Layout or simple add a global link in all SharePoint Sites without changing the Masterpages.
When i had 9 year old i was learning on how to make a newspaper article and teach me i should always answer the following questions:
  • What?
  • Who?
  • Where?
  • When?
  • Why?
  • How?
The most 6 important questions you must ask yourself every time one person request you something that i incorporate when i am working with SharePoint.

Who?
Delegate Control already exist from older versions of SharePoint and can be very usefull when we want to create global Action that have impact in one or more SharePoint Sites.
There are a lot of articles talking on how we can use Delegate control "example" and don't wan't to repeat and make more "Social 2.0 noise...".

I already see a lot of article explaining on how easy is to Create/change global controls but you need to be carefull and think what are the consequence of this changes,
By default some of this delegates control already have features associated and if you want to change you will need to be carefull to don't deactivate or remove the OOB actions associated, for example if you change or add features in the delegate control "GlobalSiteLink3,GlobalSiteLink2"

If you access the Element file "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\SocialRibbonControl\SocialDelegateControl.xml" you can see this control already have actions associated and if you change or add new control you can broke the normal behavior of SharePoint Sites.

Content of "DelegateControl.xml":
<Control Id="GlobalSiteLink3" Sequence="100"
  ControlClass="Microsoft.SharePoint.Portal.WebControls.SocialNotificationControl"
  ControlAssembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
 <Control Id="GlobalSiteLink3-mini" Sequence="100"
  ControlClass="Microsoft.SharePoint.Portal.WebControls.SocialNotificationMiniControl"
  ControlAssembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
 <Control Id="GlobalSiteLink2" Sequence="100" ControlSrc="~/_controltemplates/socialdata.ascx" />
 <Control Id="GlobalSiteLink2-mini" Sequence="100"
  ControlClass="Microsoft.SharePoint.Portal.WebControls.SocialNavigationControl"
  ControlAssembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />

But for this article i want to make focus in the "AdditionalPageHead" control.
This control is somehow more special then others because one property "AllowMultipleControls".

This property give the ability to add multiple controls without Deactivating/overwrite existing OOB controls, giving more flexibility injecting ECMAScript and users/custom Controls.

 Some Out of the Box Delegate Controls:







  • AdditionalPageHead - Delegate controlo allocated in top site - AllowMultipleControls
  • GlobalSiteLink0
  • GlobalSiteLink1
  • GlobalSiteLink2
  • SmallSearchInputBox
  • TopNavigationDataSource
  • PublishingConsole
  • QuickLaunchDataSource

  • What?
     I want to create a global link in top left of Welcome Control to be accesible in all SharePoint Sites.


    For this change was used the Internet explorer developer Tool to detect how the Welcome Control was added and inject some Javascript to make the change using  firebug.


    After the Script is created, make a litle test in the current SharePoint Page, edit the Page and add Form Web Part and inject the following Javascript:

    <script type="text/javascript">
        ExecuteOrDelayUntilScriptLoaded(LoadLink, "sp.js");
    
        function LoadLink() {
            var myMenuContainer = document.getElementById('RibbonContainer-TabRowRight').children[2].children[0];
            var newSpan = document.createElement("span");
    
            newSpan.innerHTML = '<a class="ms-menu-a"  style="cursor:pointer;white-space:nowrap;"   href="#" onclick="window.location=\'http://www.sharepointpt.org\';return false;"><span>SharePoint PT</span></a>';
            newSpan.className = 'ms-SPLink ms-SpLinkButtonInActive ms-welcomeMenu';
    
            myMenuContainer.insertBefore(newSpan, myMenuContainer.children[1]);
        }
        
    
    </script>
    

    When?
    Load javascript after the page is loaded because the javascript needs to indentify the HTML ID "RibbonContainer-TabRowRight".
    ExecuteOrDelayUntilScriptLoaded(LoadLink, "sp.js");

    Why?
    I use Delegate Control to dont change Masterpages for all Sites...

    Where?
    To response this request Globaly was created a Visual Studio 2010 SharePoint Solution with Feature, since this solution need to be deployed globaly is used a Farm Solution.
    We can define differents scopes where this Feature can be deployed "Farm, WebApplication, Site, Web", but if you install/activate with Scope "Farm" the Central Administration will also have the Support Link, i can recomend "Farm, WebApplication Scope"  depending what you want to manage.

    Create a User control where will have your code...
    [Hive]CONTROLTEMPLATES\CustomHeader\CustomHeader.ascx

    Content of CustomHeader.ascx "You can also include Server Side code to add multiple actions"

    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomHeader.ascx.cs" Inherits="CustomHeader.CONTROLTEMPLATES.CustomHeader.CustomHeader" %>
    <script type="text/javascript">
        ExecuteOrDelayUntilScriptLoaded(LoadLink, "sp.js");
    
        function LoadLink() {
            var myMenuContainer = document.getElementById('RibbonContainer-TabRowRight').children[2].children[0];
            var newSpan = document.createElement("span");
    
            newSpan.innerHTML = '<a class="ms-menu-a"  style="cursor:pointer;white-space:nowrap;"   href="#" onclick="window.location=\'https://www.sharepointpt.org\';return false;"><span>SharePoint PT</span></a>';
            newSpan.className = 'ms-SPLink ms-SpLinkButtonInActive ms-welcomeMenu';
    
            myMenuContainer.insertBefore(newSpan, myMenuContainer.children[1]);
        }
        
    
    </script>

    Elements File
    Reference to User control used to add custom control or inject Javascript.






    <?xml version="1.0" encoding="utf-8"?> 
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Control Id="AdditionalPageHead" Sequence="100" ControlSrc="~/_CONTROLTEMPLATES/CustomHeader/CustomHeader.ascx"></Control> 
    </Elements> 

    After deployed the Solution the link will be visible in top right of the SharePoint Site.




    The "How?" is the process taken to response all other questions.

    Support links:
    Delegate Control
    http://msdn.microsoft.com/en-us/library/ms463169.aspx
    How to: Customize a Delegate Control
    http://msdn.microsoft.com/en-us/library/ms470880.aspx
    AllowMultipleControls
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.delegatecontrol.aspx
    Replace SharePoint 2010 Search Box using Delegate Control
    http://msmvps.com/blogs/sundar_narasiman/archive/2011/02/19/sharepoint-2010-delegate-control-to-replace-smallsearchinputbox.aspx
    Using the Delegate Control
    http://www.sharepointnutsandbolts.com/2007/06/using-delegate-control.html
    Useful Delegate Controls in Windows SharePoint Services 3.0
    http://www.wictorwilen.se/Post/Useful-Delegate-Controls-in-Windows-SharePoint-Services-30.aspx

    PS: This script was only tested with Team Site Templates, you will need validate the other templates or change the script to have the same behavior.

    ---------------------------------------------------------------------------------------------------
    Updated 05.03.2012

    The code is updated ttrying to response all Templates

    <script type="text/javascript">
        ExecuteOrDelayUntilScriptLoaded(LoadLink, "sp.js");
        function LoadLink() {
    function getByClass (className, parent) {
      parent || (parent=document);
      var descendants=parent.getElementsByTagName('*'), i=-1, e, result=[];
      while (e=descendants[++i]) {
        ((' '+(e['class']||e.className)+' ').indexOf(' '+className+' ') > -1) && result.push(e);
      }
      return result;
    }
            var myMenuContainer = getByClass ( 'ms-welcomeMenu' )[0].parentNode ;
            var newSpan = document.createElement("span");
            newSpan.innerHTML = '<a class="ms-menu-a"  style="cursor:pointer;white-space:nowrap;"   href="#" onclick="window.location=\'http://www.sharepointpt.org\';return false;"><span>SharePoint PT</span></a>';
            newSpan.className = 'ms-SPLink ms-SpLinkButtonInActive ms-welcomeMenu';
            myMenuContainer.insertBefore(newSpan, myMenuContainer.children[1]);
        }
    </script>
    <noscript>
            Your browser does not support JavaScript!
    </noscript>

    ---------------------------------------------------------------------------------------------------
    Code updated 08-05-2012 (improved efficiency in load)


    typeof (ExecuteOrDelayUntilBodyLoaded) != "undefined" && ExecuteOrDelayUntilBodyLoaded(function () {
            var welcomeMenuContainer, linkSpan;

            //build link markup
            linkSpan = document.createElement('span');
            linkSpan.className = 'ms-SPLink ms-SpLinkButtonInActive ms-welcomeMenu';
            linkSpan.innerHTML = '<a class="ms-menu-a" style="cursor:pointer; white-space:nowrap;" href="#" onclick="window.location=\'http://www.sharepointpt.org\'; return false;"><span>SharePoint PT</span></a>';

            //inject link markup
            welcomeMenuContainer = GetElementByClassName(window.document, 'ms-welcomeMenu').parentNode;
            welcomeMenuContainer.insertBefore(linkSpan, welcomeMenuContainer.children[1]);
        });

    Thank you Marco Oechslin. :)
    Link to Project.

    Hope this help,
    Kind regards

    Sunday, January 01, 2012

    My 3º time as SharePoint MVP



    For the third time was nominated SharePoint MVP and i want to thank you all, Blog readers, twitter, Microsoft Forums and all the other Web 2.0 tools used to read about what i write.
    I want to wish you a very nice year of 2012 and I want to send to my country "Portugal" a word of hope never give up like our Grandparents never give up, even if you are out of Portugal as me, remember we always survive and resolve all the problems with big difficulties. Portugal always incentivated the MacGyver culture but that is not enough in a Global economy, we need training, learn new approachs and Vision for the future and really hope all the emigrated with degrees and High Education  can use what they learn to increase their quality of life and also improve their home country, this is my expectations for a greater future and believe in theirself in this 2012.

    Have a nice 2012 for ALL with a lot of SharePoint.

    Thank you for all your support. :)