Archive

Author Archive

SharePoint 2010 Experience in New Site of SharePoint 2013

July 22nd, 2012 Comments off

One interesting thing I have noticed in SharePoint 2013 preview is that when you create a new site there is an option to select the site experience. You can choose from 2013 and 2010. Obviously 2013 is the default option. You can see the below snapshot for quick reference.

You can also see from the image that there is a new site template (Product Catalog) available in SharePoint 2013 for publishing sites. When you select 2010 template, your page will refresh and will only show the two site templates Publishing Portal and Enterprise Wiki.

Your 2013 site using Publishing Portal will look like this.

If you select the 2010 experience for new site. Your site using the same Publishing Portal site template will look like this.

Cheers!

Run the Configuration Wizard for SharePoint 2013

July 21st, 2012 Comments off

One you have completed the Installation as mentioned in the previous blog. Now it is time to run the SharePoint 2013 configuration wizard. If you have done it with SharePoint 2007 and 2010 then it won’t be different really.

Just click Next on screen 1.

It will prompt to start a few services. Click Yes and continue.

It will start the process. On step 2 or 3 you can see a Configuration Failed error. If you see this error then solution is provided in my earlier blog.

As you know it is just a preview so you may also see an error on Step 8. When it creates Sample Data. You can simply ignore this issue. Because it is just creation of sample data.

Once your configuration is completed you can start the central admin site. Yeah, your SharePoint 15 is all set up now.

Cheers

Steps to Install SharePoint 2013 – (Preview)

July 21st, 2012 3 comments

Finally the day is here when I’m doing my first install of SharePoint 2013. I think every SharePoint person was waiting for this time eagerly. So come to point and see the steps here.

I created a VM using VMWare. I allocated 6GB memory for the SP2013. I hope it will work. Also it is mentioned to have at least 6GB memory for development machine. So hopeful!

First install the Windows Server 2008 R2. I prefer to avoid Windows Server 2012 release candidate. Then it would be too much risk to use all the pre final software. Then installed the SQL server 2012. It was very straight forward. You can also install SQL Server 2008 R2.

Now the main thing, yes SharePoint 2013. Start the installation. First screen is the same looking as SharePoint 2010. Click on the Install software prerequisites.

It will show the list of all the prerequisites. Just click the Next.

Accept the terms and click Next.

When It finish the process. It will show the Finish screen. One thing it will take some minutes to finish so be patient.

At this point it will ask you to restart the computer. After the restart it will start the process again and install few more configuration items.

When it finishes all the pre requisites installation it will show a final screen.

You need to restart your machine manually here. It will complete the pre requisites installation.

Now double click the SharePoint setup again. It will open the main screen again. Click on Install SharePoint Server. It will start the SharePoint installation.

Enter the product key provided by Microsoft.

Accept the terms and conditions on next screen.

If you are installing everything on one machine then choose Stand-alone. If you are doing a multiple server farm then you will select Complete. In Complete mode you will also need to provide the domain user account. Your local account will not be acceptable for connecting to databases.

It will start the process.

When it finishes the process it will ask to start configuration wizard. Now here it is up to you if you can’t to start configuration now or some other time. But the installation is done.

Have fun!

SharePoint 2012 – Configuration Failed to Create / Connect Configuration Database

July 21st, 2012 Comments off

Great you run the SharePoint 2013 configuration wizard and it gives you error on Step 2 or 3. Configuration Failed as the message is

“Failed to create the configuration database”.

Interestingly this error is reported with Stand Alone installations.  In fact when your machine is not connected to AD and service is running under Network Service account then it cannot create configuration database.

Solution is simple as well. Open command prompt and point to the bin directory in 15 hive. Yes now it is 15 hive. Run this command…..

psconfig.exe -cmd Configdb create SkipRegisterAsDistributedCacheHost

It will create the database. Now you can run the configuration wizard again.

Cheers

SharePoint 2013 Important Links

July 19th, 2012 Comments off

SharePoint 2013 is really hot now a days. Here you can find some important links to grab some information and download links for SharePoint 2013.

SharePoint Server 2013 Preview Download:
http://technet.microsoft.com/en-US/evalcenter/hh973397

SharePoint Foundation 2013 Preview Download:
http://www.microsoft.com/en-us/download/details.aspx?id=30345

SharePoint 2013 & Office 2013 Training For Developers:
http://msdn.microsoft.com/en-US/sharepoint/fp123633

SharePoint 2013 Training For IT Pros:
http://technet.microsoft.com/en-US/sharepoint/fp123606

Start: Set up the development environment for SharePoint 2013:
http://msdn.microsoft.com/en-us/library/ee554869(v=office.15)

Cheers

Categories: SharePoint 2013 Tags:

Configure Retention Policy through Code

September 4th, 2011 Comments off

Information Policies are nice to have it. It is also a reasonably simple job to configure an IM policy through user interface. But in order to automate the process, sometime you want to configure IM policies from code. In the below example I will give you some hint that how you can configure retention policy from the code. 

For this test I have created a content type in content type hub. Yes I recommend, plan your content types properly and use content type hub on all the possible places. It is a great feature in SharePoint 2010. Alright back to the today’s topic. Open visual studio 2010 and create a feature. Add a feature receiver to the feature and start writing the code. 

Something is better to understand on the first hand about retention policy. Retention policy can be defined for records and non-records.  Also you can set different stages for a retention policy and can set different actions for each stage. 

/// <summary>
/// Defines a constant used as the key for the workflow template name.
/// </summary>
private const string WorkFlowTemplateName = "Disposition Approval";

/// <summary>
/// Defines a constant used as the key for the Records Centre name to use in SendTo link.
/// </summary>
private const string RecordCenterNameForSendTo = "Corporate Records Centre";

/// <summary>
/// Defines a constant used as the key for the Records Centre name to use in SendTo link.
/// </summary>
private const string RecordCenterURLForSendTo = "<a href="http://archive/_vti_bin/officialfile.asmx">http://archive/_vti_bin/officialfile.asmx</a>";

/// <summary>
/// Gets or sets the SendTo ID.
/// </summary>
protected string SendToId { get; set; }

/// <summary>
/// This method will publish the content types from Content Type Hub.
/// </summary>
/// <param name="properties">The SPFeatureReceiverProperties object.</param>
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    try
    {
        if (properties == null)
        {
            throw new ArgumentNullException("properties");
        }

        SPSite site = properties.Feature.Parent as SPSite;

        using (SPWeb web = site.OpenWeb(site.RootWeb.ID))
        {
            this.SendToId = GetRCSendToLinkId(site);

            string ctypeName = "MyContentType";
            SPContentType ctype = web.ContentTypes[ctypeName];
            this.AddPolicyToContentType(ctype); 
        }
    }
    catch (Exception e)
    {
        // handle the exception here
    }
}

/// <summary>
/// Returns the SPOfficialFileHost for record center SendTo link.
/// </summary>
/// <param name="site">The feature parent SPSite object.</param>
/// <returns>ID of the send to link.</returns>
protected static string GetRCSendToLinkId(SPSite site)
{
     string sendToID = string.Empty;
     if (site != null)
     {
         string sendToHostName = string.Empty;

         SPSecurity.RunWithElevatedPrivileges(delegate
         {
             SPWebApplication webApp = site.WebApplication;
             for (int i = 0; i < webApp.OfficialFileHosts.Count; i++)
             {
                 SPOfficialFileHost host = webApp.OfficialFileHosts[i];
                 sendToHostName = host.OfficialFileName;

                 if (sendToHostName.Equals(RecordCenterNameForSendTo))
                 {
                     sendToID = host.UniqueId.ToString();
                     break;
                 }
             }
         });
     }

     return sendToID;
}

/// <summary>
/// Add a policy to content type.
/// </summary>
/// <param name="ctype">The content type.</param>
protected void AddPolicyToContentType(SPContentType ctype)
{
    string policyFeatureId = "Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration";

    Policy policy = Policy.GetPolicy(ctype);

    if (policy == null)
    {
        Policy.CreatePolicy(ctype, null);
        policy = Policy.GetPolicy(ctype);
    }

    if (policy.Items[policyFeatureId] == null)
    {
        string customData = string.Empty;

        if (ctype != null)
        {
            string workflowID = string.Empty;
            SPWorkflowAssociation workflowTemplate = ctype.WorkflowAssociations.GetAssociationByName(WorkFlowTemplateName, System.Globalization.CultureInfo.CurrentCulture);

            if (workflowTemplate != null)
            {
                workflowID = workflowTemplate.ParentAssociationId.ToString();
            }

            string ctypeName = ctype.Name;

            if (ctypeName.Equals("MyContentType"))
            {�
                customData = "<Schedules nextStageId='4' default=\"false\">"
                    + "<Schedule type='Default'>"
                    + "<stages>"
                    + "<data stageId='1'>"
                    + "<formula id=\"Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration.Formula.BuiltIn\">"
                        + "<number>1</number>"
                        + "<property>Modified</property>"
                        + "<period>Years</period>"
                    + "</formula>"
                    + "<action type=\"action\" id=\"Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration.Action.DeletePreviousVersions\" />"
                    + "</data>"
                    + "<data stageId='2'>"
                    + "<formula id=\"Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration.Formula.BuiltIn\">"
                        + "<number>1</number>"
                        + "<property>Modified</property>"
                        + "<period>Years</period>"
                    + "</formula>"
                    + "<action type=\"action\" id=\"Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration.Action.SubmitFileLink\" destnExplanation=\"Transferred due to organizational policy\" destnId=\"" + this.SendToId + "\" destnName=\"" + RecordCenterNameForSendTo + "\" destnUrl=\"" + RecordCenterURLForSendTo + "\" />"
                    + "</data>"
                    + "</stages>"
                    + "</Schedule>"
                    + "<Schedule type='Record'>"
                    + "<stages>"
                    + "<data stageId='3' recur='true' offset='1' unit='years'>"
                    + "<formula id=\"Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration.Formula.BuiltIn\">"
                        + "<number>10</number>"
                        + "<property>_vti_ItemDeclaredRecord</property>"
                        + "<period>Years</period>"
                    + "</formula>"
                    + "<action type=\"workflow\" id=\"" + workflowID + "\" />"
                    + "</data>"
                    + "</stages>"
                    + "</Schedule>"
                    + "</Schedules>";

                policy.Items.Add(policyFeatureId, customData);
            }
        }
    }
}

So what the above code is doing. It is creating a retention policy for provided content type. It is creating
retention policy for non-records (documents) and for records. As you can see you can define multiple stages
for policy. In each stage you can define different actions. Here in first stage it is deleting all the
previous versions and in next stage moving document to record centre. In my case record centre name is
Corporate Record Centre. For records it is staring a disposition workflow after a defined time.
You have to create this disposition workflow for the content type separately.

So that’s all really. Here how it looks after the feature activation.

Have fun ……… :)

Replace the In place Record Action Item in Ribbon

August 26th, 2011 Comments off

Recently I worked on an interesting work item. I have been asked to change the In place record action item image in SharePoint ribbon. As you might know adding a custom action in ribbon is just a piece of cake. But when I started looking for records action item, I couldn’t find it in the list of all default custom actions.

So I did some more work on it and found the feature which is adding the custom action.  It is available in 14 hives with the name InPlaceRecords. It uses an action.xml element file. This file defines the custom action for In place record icon in ribbon. Here is the xml for this action file.

<?xml version="1.0" encoding="utf-8"?>
<!-- _lcid="1033" _version="14.0.4758" _dal="1" -->
<!-- _LocalBinding -->
<Elements xmlns="<a href="http://schemas.microsoft.com/sharepoint/">http://schemas.microsoft.com/sharepoint/</a>">
    <Control
        Id="AdditionalPageHead"
        Sequence="70"
        ControlSrc="~/_controltemplates/recordsribbon.ascx">
    </Control>
    <CustomAction
        Id="InPlaceRecordsSettingsSite"
        GroupId="SiteCollectionAdmin"
        Location="Microsoft.SharePoint.SiteSettings"
        Rights="ManageWeb"
        Sequence="110"
        Title="$Resources:dlccore, InPlaceRecords_SettingsLink">
            <UrlAction Url="_layouts/InPlaceRecordsSettings.aspx?Source=settings.aspx" />
    </CustomAction>
    <CustomAction
        Id="InPlaceRecordsSettingsList"
        GroupId="Permissions"
        Location="Microsoft.SharePoint.ListEdit"
        Rights="ManageLists"      �
        Sequence="110"
        Title="$Resources:dlccore, InPlaceRecords_ListSettingsLink">
            <UrlAction Url="_layouts/InPlaceRecordsListSettings.aspx?List={ListId}" />
    </CustomAction>
    <CustomAction
        Id="Ribbon.Documents.Manage.DeclareRecord"
        Location="CommandUI.Ribbon"
        Rights="EditListItems"
        Sequence="17"
        Title="$Resources:dlccore, InPlaceRecords_DeclareRecordButtonText">
     <CommandUIExtension>
      <CommandUIDefinitions>
       <CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
              <Button
                Id="Ribbon.Documents.Manage.DeclareRecord"
                Sequence="25"
                Command="DeclareRecord"
                LabelText="$Resources:dlccore, InPlaceRecords_DeclareRecordButtonText"
                Image16by16="/_layouts/images/declarerecorditemhs.png"
                Image32by32="/_layouts/images/declarerecorditemhh.png"
                ToolTipTitle="$Resources:dlccore, InPlaceRecords_DeclareRecordButtonText"
                ToolTipDescription="$Resources:dlccore, InPlaceRecords_DeclareRecordButtonToolTipDescription"
                TemplateAlias="o1"
              />
       </CommandUIDefinition>
      </CommandUIDefinitions>
     </CommandUIExtension>
    </CustomAction>
    <CustomAction
        Id="Ribbon.ListItems.Manage.DeclareRecord"
        Location="CommandUI.Ribbon"
        Rights="EditListItems"
        Sequence="17"
        Title="$Resources:dlccore, InPlaceRecords_DeclareRecordButtonText">
     <CommandUIExtension>
      <CommandUIDefinitions>
       <CommandUIDefinition Location="Ribbon.ListItem.Manage.Controls._children">
              <Button
                Id="Ribbon.ListItem.Manage.DeclareRecord"
                Sequence="25"
                Command="DeclareRecord"
                LabelText="$Resources:dlccore, InPlaceRecords_DeclareRecordButtonText"
                Image16by16="/_layouts/images/declarerecorditemhs.png"
                Image32by32="/_layouts/images/declarerecorditemhh.png"
                ToolTipTitle="$Resources:dlccore, InPlaceRecords_DeclareRecordButtonText"
                ToolTipDescription="$Resources:dlccore, InPlaceRecords_DeclareRecordButtonToolTipDescription"
                TemplateAlias="o1"
              />
       </CommandUIDefinition>
      </CommandUIDefinitions>
     </CommandUIExtension>
    </CustomAction>
</Elements>

Now in order to replace it I created a new feature and added an element file in it. I copied the whole action.xml in it and changed the images icon for 32 and 64 sizes. Then I deployed my solution and activated the feature. I realised it worked fine but not as expected. My new custom action was visible there but alongside default action item for In place record. So to remove the default action item, I deactivated site level feature named In Place Record Management feature. This is OOTB feature and required for In place record management.

If you select and item in a list, default In place record action item looks like this.

So that’s all really. My new custom action menu for In place record custom action look like this.

Isn’t this simple. I hope you would have enjoyed it.

Regards

Set Content Types of default list and libraries

July 6th, 2011 Comments off

We discussed the branding of the MySite through feature stapling in previous post. Now, what if you have to change the content types of the personal and shared document libraries in the personal MySites.

Unfortunately you cannot do it from feature stapling. As your feature stapler executed before the creation of document libraries and it cannot find the document libraries to set the content type. In simple words you need to set content type after site provisioning, so your code can see the document libraries. I thought we can have a control on the master page which should run on the first time user open the site. But need to run just once.

So the solution is to use the power of SharePoint delegate controls. I created a custom control and then loaded that control in a SharePoint delegate control through a feature. This control set the content types for libraries and after completing the job it deactivated the feature. This deactivation actually removes the custom user control from SharePoint Delegate control. So it executed just once and I got the desired results from an elegant solution.

Lets start the work now……

Use the same project we created last time for MySite branding. Create a custom user control in the MySiteBranding project. Your project will look like this at this stage.

Now add a new feature to hook up your custom user control in a delegate control. Add an empty element to the project and add it to the new ContentTypeFeature. Remember to set the feature scope to Site.

Now load your custom user control to the AdditionalPageHead delegate control. Change your elements.xml file as below.

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

Here is the code for custom user control. I’m assuming that you already added the content types to the site. You can add it through feature stapler.

/// <summary>
/// Defines the MySiteHook class.
/// </summary>
public partial class MySiteHook : UserControl
{
    /// <summary>
    /// Page load method.
    /// </summary>
    /// <param name="sender">object for sender</param>
    /// <param name="e">object for events args </param>
    protected void Page_Load(object sender, EventArgs e)
    {
        SPWeb web = SPContext.Current.Web;
        SPSite site = web.Site;
        string contentTypeFeatureGuid = "6369c736-eff8-4c72-9397-b56fbc456a3b";
        string personalDocLibName = "Personal Documents";
        string sharedDocLibName = "Shared Documents";
        try
        {
            web.AllowUnsafeUpdates = true;

            // Get the SPList objects
            SPList sharedList = web.Lists[sharedDocLibName];
            SPList personalList = web.Lists[personalDocLibName];

            // Your content types has to be added to the site.
            SPContentType customContentType = web.ContentTypes["Salman Docs"];
            AddAsDefaultContentType(sharedList, customContentType);
            AddAsDefaultContentType(personalList, customContentType);
            web.Update();

            // Deactivate the feature that this control is linked to so that this code will not run again.
            bool hasFeature = false;
            foreach (SPFeature feature in site.Features)
            {
                if (feature.DefinitionId.ToString().Equals(contentTypeFeatureGuid, StringComparison.CurrentCulture))
                {
                    hasFeature = true;
                    break;
                }
            }

            if (hasFeature)
            {
                site.Features.Remove(new Guid(contentTypeFeatureGuid));
            }
        }
        finally
        {
            web.AllowUnsafeUpdates = false;
        }
    }

    /// <summary>
    /// This method add the content type as default content type.
    /// </summary>
    /// <param name="list">The SPList object.</param>
    /// <param name="customContentType">The SPContentType object.</param>
    private static void AddAsDefaultContentType(SPList list, SPContentType customContentType)
    {
        // Enable content type management on this list
        list.ContentTypesEnabled = true;
        list.Update();

        // Add the custom content type
        list.ContentTypes.Add(customContentType);
        list.Update();

        // Set it as default content type
        foreach (SPContentType contentType in list.ContentTypes)
        {
            if (contentType.Name != customContentType.Name)
            {
                list.ContentTypes.Delete(contentType.Id);
                list.Update();
            }
        }
    }
}

You have no need to make any change in the master page. If you look in the default master page, you can see that AdditionalPageHead delegate control exists there.

<SharePoint:DelegateControl runat=”server” ControlId=”AdditionalPageHead” AllowMultipleControls=”true”/>

Ok so the last thing you have to do is to add your feature to site definition. Use the existing feature stapling concept and just add this feature as well in the elements file for MySiteStapler. Your feature file will look like this now.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Feature to staple with MySite host site collection -->
  <FeatureSiteTemplateAssociation Id="13719e8d-0a3d-4a1a-97a9-3e6aa9adf4c5" TemplateName="SPSMSITEHOST#0" ></FeatureSiteTemplateAssociation>
  <!-- Feature to staple with MySite personal site collection -->
  <FeatureSiteTemplateAssociation Id="13719e8d-0a3d-4a1a-97a9-3e6aa9adf4c5" TemplateName="SPSPERS#0" ></FeatureSiteTemplateAssociation>
  <!--MySiteDocs: Feature to replace content types in document libraries for MySite personal site collection-->
  <FeatureSiteTemplateAssociation Id="6369c736-eff8-4c72-9397-b56fbc456a3b" TemplateName="SPSPERS#0" ></FeatureSiteTemplateAssociation>
</Elements>

Ok all is done now just create the site with new site definition. So when you create your new MySite, it will change the master page as we discuss in the last post. Also it will load your custom control to the AdditionalPageHead delegate control. When user opens the MySite first time your control’s code will change the content type of the shared and personal document libraries. So all is done. Your project finally looks like this.

You can use this approach for anything which needs to be done after site provisioning.

MySite Branding for SharePoint 2010

July 4th, 2011 Comments off

randing of MySites is always a challenging task. It was complicated in SharePoint 2007 and still confusing in SharePoint 2010. Recently we had a requirement to applying cooperate branding for MySites. I tried to find a reasonable solution but nothing was fitting well in the required scenario. So after completion I decided to share my idea with the world.

Before start applying new branding for MySites. We need to understand that MySites are actually use two different types of site collections. First you need a MySite host site collection and then each personal site is a separate site collection. So we have to apply branding on both sites.

Now come to the main task. There could be different ways to customise the MySites. But the best possible solution would be using feature stapling. If you are new to feature stapler you can see this good post from Chris (http://www.sharepointnutsandbolts.com/2007/05/feature-stapling.html).

So we need to create first feature with Site level scope. This feature will be called MySiteStaplee. This feature will deploy master pages to the site and also change the master page for the site. Right first step would be to create a new project in Visual Studio 2010 and create a feature with Site level scope. It will look like this.

MySite Stapler Project View
Now we need to attach an elements.xml to include the master pages to deploy through this feature. Now it is bit different in Visual Studio 2010. We need to add a module. Add master page in the module, and make changes in the elements.xml file as below.

<?xml version=”1.0″ encoding=”utf-8″?>
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”>
<Module Name=”MasterPages” List=”116″ Url=”_catalogs/masterpage”>
<File Path=”MasterPages\salman.master” Url=”salman.master” Type=”GhostableInLibrary” />
</Module>
</Elements>

Your project will look like this now.

Now add a property to the master with a value as master name.

<?xml version=”1.0″ encoding=”utf-8″ ?>
<Feature xmlns=”http://schemas.microsoft.com/sharepoint/“>
<Properties>
<Property Key=”MySiteMasterPage” Value=”/_catalogs/masterpage/salman.master”/>
</Properties>
</Feature>

Next thing we need to add a feature event receiver to replace the master page for mysite. For this add feature event receiver with the MySiteStaplee. Your code for featureactivated will look like this.

/// <summary>
/// Key for MySite master.
/// </summary>
private const string MySiteMasterPage = “MySiteMasterPage”;

/// <summary>
/// Set master page on feature activation.
/// </summary>
/// <param>The SPFeatureReceiverProperties object.</param>
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite site = properties.Feature.Parent as SPSite;

if (site != null)
{
SPWeb web = site.RootWeb;
string oldMasterUrl = web.MasterUrl;

web = site.RootWeb;
string newMySiteMasterUrl = properties.Feature.Properties[MySiteMasterPage].Value;
if (!string.IsNullOrEmpty(newMySiteMasterUrl))
{
web.CustomMasterUrl = SPUrlUtility.CombineUrl(web.ServerRelativeUrl, newMySiteMasterUrl);
web.MasterUrl = SPUrlUtility.CombineUrl(web.ServerRelativeUrl, newMySiteMasterUrl);
}

web.Update();
}
}

Ok, so your staple feature is ready. Now you need a stapler to staple your feature with mysite site definition.
In order to achieve this create a new project. Create a new feature in this project with Farm level scope. It will look like this.

Now we need to staple the MySiteStaple with MySite host and MySite personal site definitions. So we need elements file here. Add a new Empty Element from Visual Studio 2010. Remember mysite host site definition’s template name is SPSMSITEHOST and MySite personal site template name is SPSPERS. Your elements file will look like this.

<?xml version=”1.0″ encoding=”utf-8″?>
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/“>
<!– Feature to staple with MySite host site collection –>
<FeatureSiteTemplateAssociation TemplateName=”SPSMSITEHOST#0″ >
</FeatureSiteTemplateAssociation>
<!– Feature to staple with MySite personal site collection –>
<FeatureSiteTemplateAssociation TemplateName=”SPSPERS#0″ >
</FeatureSiteTemplateAssociation>
</Elements>

Ok so all is done. Now you have to deploy these wsp solutions to the server. This will apply your master page with MySite host and MySite personal site definitions. So whenever you create a new MySite host or whenever a user creates his/her MySite, this feature will replace the master page for the new site. Your final solution structure will look like this in visual studio 2010.

I hope it will help you start the branding. Please wait for my next post with the advance solution required for some more branding issues with MySites.

Cheers.

Add Links in SummaryLinksWebpart using PowerShell scripting

May 23rd, 2011 Comments off

More on the automation and adding data in other webparts. In previous post I talked about loading data in ContentEditorWebpart. Now look at SummaryLinkWebpart . Recently when i was working with SummaryLinkWebpart. I realised it is a bit different then other web parts to load links in summaryEditorWebpart. I looked for the internet but I couldn’t find any single example for SummaryLinksWebpart with power shell. So here is the example for others. I hope it will help some folks.

$webpart = new-object  $typeName
$webpartType = $webpart.GetType().ToString()

if($webpartType -eq “Microsoft.SharePoint.WebPartPages.ContentEditorWebPart”)
{
        if($values)
       {
               $keyValuePairs = $values.split(“,”)
               foreach ($keyValuePair in $keyValuePairs)
              {
                       $keyValueArray = $keyValuePair.Split(“|”)

                       [string]$propertyName = $keyValueArray[0].Trim()
                       [string]$propertyValue = $keyValueArray[1].Trim()

                       $sumLink = New-Object Microsoft.SharePoint.Publishing.SummaryLink $propertyName
                       $sumLink.LinkUrl = $propertyValue
                       $webpart.SummaryLinkValue.SummaryLinks.Add($sumLink)
                       $webpart.SummaryLinkValue = $webpart.SummaryLinkValue
              }
       }
}

Cheers