Friday, 12 July 2019

SPFx Deployment & Upgrade

Package SPFx Solution

SPFx has greatly simplified the packaging and deployment of solutions. Post completing your SPFx solution development you can creating the SPFx package (.sppkg) by executing two simple commands:

  1. Gulp bundle
  2. Gulp package-solution

You can execute these commands from the Visual Studio Code Terminal. Click Terminal in the Menu bar and select ‘New Terminal’.

Gulp bundle – The gulp bundle command will generate the debug bundles for your solution. This would basically, convert the TypeScript files to JavaScript to be understood by the browser and generate the required configuration files. You can also use gulp bundle --ship to generate bundles in release mode. The '--ship' operative would indicate that the solution is ready for release.

Gulp package-solution – The gulp package-solution command would collect all the JS and configuration files generated by gulp bundle into an SPFx package. It would create a .sppkg file that can now be uploaded to the SharePoint App Catalog for deployment to the site. Similar to the gulp bundle command we can use the '--ship' operative for package-solution as well to package the solution in release mode. The command would be gulp package-solution --ship.

In conclusion, the commands for packaging the solution in debug mode are:
gulp bundle
gulp package-solution
And the commands for packaging the solution in release mode are:
gulp bundle --ship
gulp package-solution --ship

Please note: The .sppkg file packages all the SharePoint assets and Client-side assets of the SPFx solution. These assets would be hosted in a CDN defined in the write-manifest.json file’s “cdnBasePath” parameter. If you are looking to host the asset files in a pre-defined CDN location, you need to specify the location in the “cdnBasePath” of write-manifest.json file. Else, if a CDN is not specified, SharePoint will create a local CDN in the App Catalog and host the asset files. You would need to define the CDN path before bundling and packaging the solution.

Default CDN:

Custom CDN:


Upload and Install Solution to SharePoint

Once you run the gulp package-solution command the SPFx package file (.sppkg) is created. This file is located in the SharePoint --> Solution folder of your main folder. The file name can be modified from the package-solution.json file in the ‘Config’ folder. The ‘solution’ tag in the file defines the details of the package file created.


You can modify these details and execute the bundle and package-solution commands again.

To apply this package to our SharePoint site you need to:
  1. Provision App Catalog – The App Catalog can be provisioned at a tenant level or site collection level for SharePoint Online. For SharePoint on-premise the App Catalog can be provisioned at a web application level or site collection level.
    1. App Catalog at Web Application Level – You can create an App Catalog and associate it with a Web Application for SharePoint on premise by browsing to the Central Administration site --> Browse to ‘Apps’ from the left navigation --> In the screen that appears select ‘Create a new App Catalog site’ and provision your app catalog.
    2. App Catalog at Site Collection Level – You can provision an App Catalog for your Site Collection by running the following commands:
    3. SharePoint Online – Start SharePoint Online Management Shell and execute the following commands:
      Connect-SPOService -Url [Your SharePoint Admin Site URL here]
      $site = Get-SPOSite [Your Site Collection URL here]
      Add-SPOSiteCollectionAppCatalog -Site $site 


      SharePoint On-Premise – Download and install the PnP SharePoint Powershell commands and execute the following commands for your site:
      $site = Get-SPSite [Your Site Collection URL here]
      Add-PnPSiteCollectionAppCatalog -Site $site

      The site collection App Catalog will be available in the Site Contents page of the root site of the site collection. It will be named ‘Apps for SharePoint’.
  2. Upload the .sppkg file to the App Catalog – Upload the .sppkg file from the Solution folder to the SharePoint App Catalog. On uploading the solution, a dialog will be displayed to deploy to the solution to SharePoint site. Click ‘Deploy’.

  3. Add the web part to the site – Navigate to the site contents of your site and click ‘New’ in the top ribbon. A popup menu appears, select ‘App’.


    You can now select the App you have installed and add it to your site collection. If your App contains an extension the customizations will be directly applied to your site. If your App contains a web part, you will now be able to add the web part to the SharePoint page.

Upgrade SPFx Solution

In case there are any changes to your deployed solution that you would like to release as an upgrade, you can follow the below steps to upgrade the SPFx solution.
  1. Re-package the Solution – You would need to change the version number and rerun the packaging commands to re-package the solution.
    1. Open the ‘package-solution.json’ file in the ‘config’ folder.
    2. Update the version number for the solution parameter and save the file.
    3. Re-execute the gulp bundle --ship and gulp package-solution --ship from the terminal as done during solution packaging.
      Please note: Changing the version number to a new incremental number (major version or minor version) is mandatory to allow us to upgrade the application.
  2. Upload the Solution to SharePoint – Post re-packaging the solution the .sppkg file will be available in the sharepoint --> solution folder. You would need to upload the file to the same App Catalog. A popup will appear asking you to “Replace the file” or “Don’t upload”. Select the “Replace the file” option and check-in the solution file.
    Please select the solution and click “Deploy” from the “Files” tab in the top ribbon, if the app is not automatically deployed.

    Please note: the “Deploy” button will be disabled if the app is already deployed. In case, it is disabled you can continue further.
  3. Upgrade the Installed SPFx Solution – For upgrading the solution:
    1. Browse to the Site Contents page of the site.
    2. Click on “Return to Classic SharePoint” below the Quick Launch
      Please note: If you are unable to see the “Return to Classic SharePoint” button you can simply try to delete your app. It should take you back to the Classic SharePoint UI.




    3. In the classic SharePoint UI click on the ellipsis beside your app and click 'About'.

    4. In the popup screen that appears you will find the following message: A newer version of this App is available followed by a “Get It” button. Click on “Get It” to upgrade your App.

Friday, 28 June 2019

SPFx Solution Components

Scaffold your SPFx Solution

Run Command Prompt as Administrator and execute the following command to scaffold your SPFx Solution -
Please note: If you have installed the NodeJS components globally (as system administrator), you can execute the commands from any folder. However, in case you have installed the NodeJS components without administrator privileges, you would need to execute these commands from the local folder where node modules are located.

  1. Through Command Prompt, browse to the folder where you would like to create your solution
  2. Run yo @microsoft/sharepoint
    Please note: the @microsoft/sharepoint generator command would require you to install the SharePoint generator through npm. You need to execute npm install @microsoft/generator-sharepoint -g (‘-g’ switch would install the generator globally, do not use this switch if you would like to install the generator in the local folder only)
  3. A list of questions would be posted to you to enable the generator to scaffold the solution accordingly. They are:
    1. What is your solution name?
    2. Which baseline packages do you want to target for your component(s)?
      Ideally, SharePoint Online only (latest) would provide you with the latest SPFx framework and components, however, if you are planning to install your solutions on SharePoint 2019 on-premise then you would have to select SharePoint 2019 as the option here. There are specific settings for 2019 solutions which are not available on SharePoint Online.
    3. Where do you want to place the current files?
      You can place the files in the current folder OR create a sub-folder with the solution name. I would prefer creating a sub-folder as this would group all my project files together instead of them lying all around in a used folder. It would also help you open the source folder using an editor like Visual Studio Code.
    4. Do you want to allow tenant admin the choice of being able to deploy the solution to all sites immediately without running any feature deployment?
      The SPFx solution is deployed to a SharePoint site using the Feature framework. The activation or de-activation of the feature would make the solution available or remove it. If you answer ‘Yes’ here, the feature implementation step would be skipped, and the web part/extension would be available to all sites in the tenant on installation. However, if you have certain SharePoint artefacts to be deployed, you would need to answer ‘No’, as those would mandate the feature installation step. In my view, the feature installation step allows more control to administrators to enable/disable the SPFx solution.
    5. Which type of client component to create?
      Web Part or Extension (In case you select Extension, it would as you for the type of extension) 
    6. What is your Web Part/Extension name?
    7. What is your Web Part/Extension description?
    8. Which framework would you like to use?
      I would prefer ‘No JavaScript framework’ as this would allow the flexibility of adding components I need later.
Please check the screen-clipping below with a sample set of answers:


Post this the solution would be scaffolded and available at the location specified.Post this the solution would be scaffolded and available at the location specified.

Open the Solution with Visual Studio Code

Post scaffolding a directory with the solution name would be created.

  1. You can start Visual Studio Code (Right click  Run as administrator). 
  2. From the ‘File’ menu select ‘Open Folder...’.
  3. Browse and select the folder where the solution was scaffolded.

The solution files should appear as below:



Significant Components of SPFx Solution

Certain key files and components of the SPFx solution (refer image above) are listed below:

  1. Config folder – contains the configuration related files for the solution
    1. Config.json – Primarily defines the entry point and manifest files of the solution. You would not need to make any changes to this file
    2. Package-solution.json – Defines the features of the .sppkg file that will be created when the solution is prepared for deployment. Key elements such as package file name, package version, package name and whether client-side assets will be included.
    3. Serve.json – Basically used for defining the start page and port when testing the solution using ‘gulp serve’
    4. Write-manifests.json – In case you have a custom CDN defined for your SharePoint assets, you can defined the CDN path in this file. Custom CDN would be useful in case of a tenant used over multiple geographies. However, if the CDN path is not set, SharePoint would host the files on a default CDN from where they can be provisioned.
  2. Node_modules folder – contains all the node modules that are installed for the solution. This is a bulky folder and usually not managed by the developer. All modules installed will be placed in the node_modules folder.
  3. Src folder – This is the key folder where the web part/extension files will be placed. It would ideally contain
    1. TypeScript file – Which would define the functionality of the WebPart/Extension. The TypeScript (.ts) file would contain a render function where you can define what your component will render.
    2. JSON file – This is a manifest file which would be used to convert the TypeScript file to JavaScript file (as browser cannot understand TypeScript). Developers would not need to make any changes to this file.
    3. SCSS file – This is a stylesheet file included to define the styles only for Web Parts. This file would not be present for extensions.
  4. Temp folder – This folder contains the converted JS files (converted from TypeScript). This folder would be used to host and render the files when ‘gulp serve’ command is executed.
  5. Gulpfile.js – This file contains the definition of all the gulp commands that we would execute for serving, bundling and packaging our solution
  6. SharePoint folder – This folder is not present initially as part of the solution. Once, we execute ‘gulp package-solution’ command this folder is created. It contains the SharePoint Package (.sppkg) file that can be uploaded to the SharePoint App Catalog.




Monday, 17 June 2019

SharePoint SPFx Setup Without Administrative Rights

SPFx Setup


Requirements:


  1. NodeJS package installed on your machine
  2. Code editor such as Visual Studio Code

These are freeware and can be downloaded from the web and installed locally.

SPFx Setup for Windows (With Administrator Access):

To simplify the entire setup process (if you do have administrator access on your machine), it can be broken down into 3 simple steps:

  1. Download NodeJS MSI installer and execute the installer as administrator
    • You can download the NodeJS installer from: https://nodejs.org/en/
    • After the download completes, execute the MSI file. Generally, this would install all the necessary files, register the node command in the global variables and download all required files in the Program Files/NodeJS folder.
  2. Download and install Visual Studio Code
    • You can download Visual Studio Code from: https://code.visualstudio.com/
    • Run the exe file to install Visual Studio Code
      Please note: You can use any other code editor you are comfortable with – Atom, Webstorm etc.
  3. Install the necessary tools for development – Yeoman, Gulp and SharePoint Generator, you would use the following commands from Command Prompt:
    • Globally install Gulp and Yeoman –
      npm install -g yo gulp
    • Globally install SharePoint Generator –
      npm install -g @microsoft/generator-sharepoint
    • These commands would need to download files from the internet and install them locally, if you are behind a corporate proxy, you would need to set the proxy in the npm config files using the following commands:
      npm config set proxy [Your Proxy URL]
      npm config set https-proxy [Your Proxy URL]

SPFx Setup for Windows (Without Administrator Access on local machine):

In some cases, it would be possible that users do not have administrator access on their local machines, which would prevent them from running NodeJS installation. Below are the steps for setting up your development environment for SPFx, without administrative privileges:

  1. Download the NodeJS zip folder for version 8.x and extract files locally
    • You can download the NodeJS zip for version 8.x from: https://nodejs.org/dist/latest-v8.x/
    • Copy the zip folder to a dedicated local location and extract all files. You will have a folder with the Node version as node-v8.x… This folder will contain the node.exe application
    • Copy the path to the of the node.exe file and add it to the local environment variables of your machine.
      Please note: The local environment variables would allow you to execute the node.exe commands from any location of your machine, however, local environment variables work on a per user basis and would need to be installed for each user separately
  2. Download and install Visual Studio Code
    • You can download Visual Studio Code from: https://code.visualstudio.com/
    • Run the exe file to install Visual Studio Code
      Please note: Visual Studio Code installation would not need Administrator privileges.
  3. Install the necessary tools for development – Yeoman, Gulp and SharePoint Generator. Start Command Prompt and navigate to the folder where you would create your SPFx solution. You would use the following commands from Command Prompt:
    • Install Gulp and Yeoman locally –
      npm install yo gulp
    • Install SharePoint Generator locally –
      npm install @microsoft/generator-sharepoint
    • These commands would need to download files from the internet and install them locally, if you are behind a corporate proxy, you would need to set the proxy in the npm config files using the following commands:
      npm config set proxy [Your Proxy URL]
      npm config set https-proxy [Your Proxy URL]

      Please note: The commands used here would add all the necessary node modules to the defined folder only. Referencing those modules outside the scope of that folder would not be possible
A significant portion of this blog is referred from: Set up your SharePoint Framework development environment

However, I have tried to rephrase and simplify the information to my best ability.


Tuesday, 3 June 2014

Steps to perform Upgrade (apply Patches) on your SharePoint Farm

These are certain basic steps to be followed whenever you install SharePoint service packs or cumulative updates on your SharePoint Farm:
  1. Take a backup of your farm - Farm backup is required but since CUs also make changes to the System Registry it is always a good idea to take a registry backup or better create an image of the existing system before applying patches. Preferably you can also keep screen shots of the services on server page for each server and the features installed in the farm to cross-check the status post installation is completed.
  2. Stop the IIS World Wide Web Publishing service (W3SVC) on all your WFEs.
  3. Install the patch (CU or SP) on the server which hosts the Central Administration first.
  4. Restart the server hosting the Central Administration, once the patch has installed successfully.
  5. Install the patch on each server (one at a time) other than your Central Administration server.
  6. Restart each server (right after the patch installation completes successfully).
  7. Run the Configuration Wizard on each server (starting with the server hosting the Central Administration site and then on each other server in the farm).
  8. Optionally, you can do one more restart of all the servers once Configuration Wizard has been run on all of them.
  9. Start the IIS World Wide Web Publishing (W3SVC) service and check your system.
Things to check once the update has been executed:
  1. Check for the System Services - SharePoint 2010 Timer Service, SharePoint 2010 Administration service etc.
  2. Check for the SharePoint services on the Central Administration - Services on Server page. They should be as they were earlier.
  3. Check IIS Application Pools and websites
Obviously, you would not be installing SharePoint updates on your Database server and finally, all this is easier said than done. These are just the general guidelines to be followed.


You would definitely be facing a whole bunch of exceptions during the process of installing the upgrades unless it is a new installation :). Those need to be taken care of based on the issues faced.


Hope this is helpful to at least understand the procedure to install upgrades.

Monday, 5 May 2014

A Web Part with this ID has already been added to this page - Creating SharePoint App

I started with creating my first ever SharePoint App for SharePoint Online following this link. However, on trying to deploy my App I received the following error -


"A Web Part with this ID has already been added to this page".


I tried removing the web part (XSLT List View Web Part) and redeploying (please note that I was using NAPA for my development here) but that didn't work


I found this interesting blog post after Googling around and I appreciate the effort put in my Dragos here. According, to the post the reference of the Web Part is stored in the Content Database in the AllWebParts table mapped with the page on which it is placed. Usually, we add a web part to the SharePoint page using the SharePoint UI and delete it the same way. This would definitely add/delete the reference of the web part from the Content Database as well. However, since I was adding and removing the reference of the web part through HTML in my app, this would obviously not trigger the database for updating the reference.


Now, as I mentioned earlier, I am using SharePoint Online and therefore, cannot interfere with the database, so Dragos' solution would not work for me and as it is interfering with the SharePoint Content Database is out of limits.


So, since I could not delete the reference of the web part mapped against my page, I changed the name of my page and redeployed. And it worked!


Doesn't really help much if you are starting with a new app, but can save a lot of time if you have already implemented major functionality in your App. Either ways, it is interesting to understand the internal functioning of SharePoint.


Once again, really appreciate the MSDN Link and Drago's Post,

Friday, 2 May 2014

Wrap Promoted Links Web Part - Display Multiple Rows

The Promoted Links List/App gives a decent effect to represent static links instead of the Summary Links Web Part or the Links List in SharePoint 2013, though I would like to mention that Summary Links Web Part does have a few advantages.


However, in most cases the number of tiles (links) exceeds the available content area and we have a to navigate through the tiles using scroll buttons. For a relatively small number of tiles most users find this acceptable. However, if the number of tiles is too large and a certain group of users have to regularly browse till the last link, you can surely count them out of your Friend's List!


So, to ease things a bit here is a simple javascript you can use to "wrap" the Promoted Link Tiles after a set number of occurrences i.e. say you would like to display your tiles in rows of four. You need to embed the below javascript in the page where you are displaying the Promoted Link Tiles.




==Script Begin==
<script type="text/javascript" src=http://code.jquery.com/jquery-1.10.2.min.js></script>
<script type="text/javascript">
$(document).ready(function () {
   
// Update this value to the number of links you want to show per row
var numberOfLinksPerRow = 4;
   
// local variables
var pre = "<tr><td><div class='ms-promlink-body' id='promlink_row_";
var post = "'></div></td></tr>";
var numberOfLinksInCurrentRow = numberOfLinksPerRow;
var currentRow = 1
// find the number of promoted links we're displaying
var numberOfPromotedLinks = $('.ms-promlink-body > .ms-tileview-tile-root').length;
  // if we have more links then we want in a row, let's continue
  if (numberOfPromotedLinks > numberOfLinksPerRow) {
    // we don't need the header anymore, no cycling through links
    $('.ms-promlink-root > .ms-promlink-header').empty();
    // let's iterate through all the links after the maximum displayed link
    for (i = numberOfLinksPerRow + 1; i <= numberOfPromotedLinks; i++) {
      // if we're reached the maximum number of links to show per row, add a new row
      // this happens the first time, with the values set initially
      if (numberOfLinksInCurrentRow == numberOfLinksPerRow) {
        // i just want the 2nd row to
        currentRow++;
        // create a new row of links
        $('.ms-promlink-root > table > tbody:last').append(pre + currentRow + post);
        // reset the number of links for the current row
        numberOfLinksInCurrentRow = 0    }    // move the Nth (numberOfLinksPerRow + 1) div to the current table row
    $('#promlink_row_' + currentRow).append($('.ms-promlink-body > .ms-tileview-tile-root:eq(' + (numberOfLinksPerRow) + ')'));   // increment the number of links in the current row
    numberOfLinksInCurrentRow++;  }
}
});
</script>
==Script End==


Please note that to display more number of tiles per row, increase the "numberOfLinksPerRow" variable. Also, it would be a good idea to give a local jQuery library reference instead of codeplex reference.


I have taken this script from the TechNet Article here.


Hopefully, you will be in the "Good Books" of all your colleagues! :)








Office Lens - Microsoft's mobile scanner

Office Lens works like a scanner with your mobile phone. It enhances pictures taken through your cell phone camera. You can convert documents, notes, expense bills to neat scanned copies and save them to One Note.


Obviously, there are a lot of available software that can perform the same job for free and can be used on multiple devices. However, the main appeal for Lens is its integration with Office applications.


Pictures from Lens are directly saved to One Note and using Office Online we can use them on multiple devices (actually any device with an internet connection). And since Microsoft Office is very much part of our daily lives it becomes easy to use the data.


Examples -
1. Whiteboard data during meetings can be easily re-used to create presentations
2. Restaurant bills can be easily converted to create expense claims.
3. Hard copies of multiple documents can be collected together and can be searched through for specific keywords using OCR.


But these are just a few of the examples that I could think of.


Lastly, Lens is now available on iDevices and hopefully will come up in PlayStore soon.


For more details - http://blogs.office.com/2014/03/17/office-lens-a-onenote-scanner-for-your-pocket/

Wednesday, 30 April 2014

Microsoft Office on iOS and Android

Microsoft Office Products are available in the App Store and Play Store!


Though Office Online does provide most office products (for home usage) to users online it is good to have the products on your device for offline usage.


This combined with the new Nokia X series phones, which operate on Android based systems shows that new Microsoft strategy to win back the user base it is losing to these systems.


You can find more information about the office products at http://office.microsoft.com/en-us/mobile

Hope we get Lync on Android soon!

Tuesday, 21 January 2014

Column Validation in SharePoint 2010 - Email and Phone Number Validation

Column Validation, I feel, is a relatively less used feature of SharePoint. If used well it can save time and lessen dependency on SharePoint Designer.

Basic validations such as date range validations or number validations can be performed by using simple expressions as well as data format validations for emails and phone numbers can be performed.

Expression for Phone validation -
=AND(
    LEN([Phone])=14,
    IF(ISERROR(FIND("(", [Phone],1)),
        FALSE,
        (FIND("(", [Phone]) = 1)
    ),
    IF(ISERROR(FIND(")", [Phone],5)),
        FALSE,
        (FIND(")", [Phone], 5) = 5)
    ),
    IF(ISERROR(FIND(" ", [Phone],6)),
        FALSE,
        (FIND(" ", [Phone], 6) = 6)
    ),
    IF(ISERROR(FIND("-", [Phone],10)),
        FALSE,
        (FIND("-", [Phone], 10) = 10)
    ),
    IF(ISERROR(1*CONCATENATE(MID([Phone], 2, 3), MID([Phone], 7, 3), MID([Phone], 11, 4))),
        FALSE,
        AND(
            1*CONCATENATE(MID([Phone], 2, 3), MID([Phone], 7, 3), MID([Phone], 11, 4)) > 1000000000,
            1*MID([Phone], 2, 3) <> 911,
            1*MID([Phone], 7, 3) <> 911,
            1*MID([Phone], 7, 3) <> 555
        )
    )
)

Expression for Email validation -
=AND(
    ISERROR(FIND(" ", [Email],1)),
    IF(ISERROR(FIND("@", [Email],2)),
        FALSE,
        AND(
            ISERROR(FIND("@",[Email], FIND("@", [Email],2)+1)),
            IF(ISERROR(FIND(".", [Email], FIND("@", [Email],2)+2)),
                FALSE,
                FIND(".", [Email], FIND("@", [Email],2)+2) < LEN([Email])
            )
        )
    )
)


I have taken these expressions from "The Chris Kent" blog. Please do visit that blog for a detailed explanation of these expressions. The links are as follows:
Finally, the pros and cons of this approach are as follows:

Pros -
  • Implementation is simple - just place the expression in the Column Validation text box
  • No customization required - no javascript/jQuery, or any other type of custom code is required.
  • Modification or management is simple
  • Replication across lists is simple
Cons -
  • Evaluating expressions for simple validations is also a tedious task
  • Due to the complexity of expressions there are limitations to the depth to which the validation can be performed. It is less flexible.
  • Error messages are displayed as field validators rather than javascript alerts (users usually prefer alerts)
- Huzefa Mala

Friday, 23 August 2013

SharePoint Document Sets - not to be confused with FOLDERS

Document Sets - in my view is a very misunderstood and commonly misused entity in SharePoint.
 
The general perception about Document Sets is that they are Folders with a Welcome Page, but there is much more to it than just that.
 
A Document Set is a separate entity while a Folder, more or less, behaves as a location. Therefore, apart from grouping related items together a Document Set can also be treated as an item in a SharePoint Library. Therefore, all operations that are applied to a SharePoint Library item can be applied to a Document Set.
 
Below is a list of features of Document Sets:
  • A Document Set contains a welcome page which can be used to give more information about what it contains. Web Parts can be added to the welcome page to give a snapshot of what the Document Set will contain.
  • It can contain separate Metadata and Site Columns from the Library in which it is contained. Metadata and Site Columns can be shared by all documents in the Document Set or can be applied to individual documents.
  • By creating Content Types inherited from Document Set, we can define default documents that will be created along with our new Content Type. Suppose, we define a Content Type for Sales Report then we can associate all Sales Reports templates with that Content Type. Each time a new Sales Report Document Set is created, all the templates will be created along with it and users can simply fill in those templates to generate their report.
  • Workflows can be associated with the entire Document Set or individual documents inside the Document Set
  • Versioning can be applied to the Document Set.
  • Specific content types can be made allowable inside a Document Set.
  • Unique permissions can be associated with a Document Set.
Below are a couple of features not available with a Document Set, when compared with a Folder:
  • Document Sets cannot be nested i.e. Document Sets cannot contain Document Sets
  • Document Sets, as the name clearly suggests, cannot be associated with SharePoint Lists.
To enable Document Sets within your site you need to activate the Document Set feature which is available at the site collection level.

Document Sets are not available with SharePoint Foundation 2010.

Below are certain links for further reading:
For limitations of Document Sets refer this link: http://www.sharepointanalysthq.com/2011/09/document-set-limitations-and-considerations-in-sharepoint-2010/

 

Monday, 12 August 2013

Configure LDAP Authentication for your SharePoint 2010 or 2013 site

Recently, I tried configuring LDAP authentication for my SharePoint 2013 application.

Obviously, in case of SharePoint 2013 we need to use Claims based authentication and we need to configure three configuration files:
  • Security Token Service web.config
  • Central Administration web.config
  • The specific web application web.config.
There are many blogs explaining the details of these configurations. Here is an interesting link that explains stuff in detail - http://sharepointchick.com/archive/2010/05/06/configuring-claims-and-forms-based-authentication-for-use-with-an.aspx

However, there is one important task that you need to perform on your LDAP server to ensure that the authentication is successful. You need to give administrative permissions to the following accounts on your LDAP server:
  • Security Token Service application pool account
  • Central Administration application pool account
  • Web application app pool account.
This simple task had me hung up for quite a few hours (or days, I can't really recollect).

The interesting thing here is that SharePoint does not give you the specific error that it cannot access the LDAP directory straight away. It throws in a lot of generic errors such as - User credentials cannot be authenticated, please check user name and password. And somewhere amongst these generic errors is hidden your real error that it cannot access the LDAP server objects for authentication.

Sunday, 21 October 2012

Set Passphrase for SharePoint 2010 Farm

The Passphrase, for your SharePoint farm, is required to add a new server to the farm.

If you have forgotten the passphrase then there is no method to retrieve or recover it but you can change it.

The passphrase resides in the SharePoint Configuration database and below are the steps to set/change it:
  1. Start SharePoint 2010 Management Shell from Start --> All Programs --> Microsoft SharePoint 2010 Products --> SharePoint 2010 Management Shell
  2. Write $passp = ConvertTo-SecureString -asPlainText -Force. This will prompt you for a string, which is going to be set as the new passphrase of your farm. The string is converted to SecureString, which is the expected type of the passphrase
  3. Next write Set-SPPassPhrase -PassPhrase $passp -Confirm. It will ask for a confirmation after which your new passphrase will be set.

Move/Change SharePoint 2010 Database Server

This, according to me, is a very possible and real -world scenario:

Your client (or your organization, for that matter) is planning to upgrade the databases, or the database architecture/topology and have come up with an entire new set of hardware which will host the databases and you are assigned the task of moving only the SharePoint databases to the new server.

Ordinarily, if this were a .NET application you would simply ask your DBA to backup/restore your databases and make changes to your connection strings in the config file and that's the end of that story. (Please note that I do not claim to be a .NET specialist and I apologize for hurting the sentiments of .NET developers if I have over-simplified the complexity of their task)

But, as I have said time and again "things are not that simple in SharePoint World"!

So, here's what Microsoft have to say about the method of achieving the database move from one server to another for SharePoint: SharePoint 2010 - Move all databases

In simple words, you need to apply an SQL alias to all your SharePoint servers in the farm, so that whenever a request for the "OLD" SharePoint Database server is sent from any SharePoint server it is redirected to the "NEW" Database server. Easier said than done!

To quote one of my colleagues - this is a very "weak" solution because -
  1. The reference of the old database server is never removed
  2. All logs and statistics mention  the old database server name.
To a person who has been newly introduced to the SharePoint farm and is debugging certain issue it is very confusing to figure out that the database server mentioned in the log files is just an alias and the actual database server is different. It could mess up his life and could potentially cause serious mental strain!

The other method is to re-create your farm and re-configure all services with the new database. Ofcourse, you would migrate the content of your Web Applications, residing in Content Databases, to the new server through backup/restores. Here is the link that sheds more light on this method. This is a possible solution if you are dealing with a small farm but if you have a multiple server farm with huge amounts of data residing in SharePoint, which has been crawled by the Search Services and User Profiles running into thousands then re-configuring all services might give you a nightmare.

I am going to concentrate on the former approach of applying aliases in this post. The steps to apply the alias and, therefore, effectively replace your database server are:
  1. Restore databases to the new database server
  2. Remove the SharePoint server from your farm
  3. Apply the SQL alias using cliconfg.exe
  4. Reconnect the SharePoint server to the same farm.
Below these steps are explained in detail, but before you do anything else, please make sure you have the passphrase for your SharePoint farm. The passphrase is required to re-connect the servers to the farm and if (like me) you had not initially setup your farm, there is very high possibility that you do NOT have the passphrase. Refer this post to set/change your farm's passphrase

Step 1 - Restore databases to the new database server -
  • Stop all SharePoint related services on all servers (except the database server) in your farm. Also, stop the IIS service on your WFEs. This is to ensure that no changes will be made to the databases while backup is in progress
  • Backup the SharePoint related databases
  • Restore to the new server
  • Start all the services

Step 2 - Remove SharePoint server from the farm -
  • Logon to your server
  • Run the SharePoint 2010 Products Configuration Wizard
  • Disconnect the server from the farm (please know the passphrase before doing this)
  • Let the wizard complete
Step 3 - Apply the SQL alias to your server -
  • Open command prompt and type cliconfg.exe and the return key
  • An SQL Network Utility will appear that will allow you to enter details of your alias
  • Click on the Alias tab and click Add
  • In the Network Libraries select TCP/IP
  • Write the old database server name in Server Alias and new database server name in Server Name text box.
  • Let the Dynamically determine port check box be selected (and select it if it is not already selected)
  • Click OK
  • Then click Apply and OK
Step 4 - Reconnect the SharePoint Server to the same farm -
  • Again start the SharePoint 2010 Products Configuration Wizard
  • Connect the server to an existing farm
  • And in the database server name provide the name of the OLD database server and select the configuration database name from the dropdown.
  • Enter your passphrase and continue through the next steps of your wizard to reconnect the server to the farm
Note that you will have to repeat steps 2 - 4 for each server in your farm.

Here is what happens next: If there are any configurational issues with any of your SharePoint services which have uptil now been suppressed, they will start surfacing after you have moved the database server. E.g. Search Topology, User Profile Synchronization etc. So, unless you claim to be a perfectionist at maintaining your farm, you will have to do quite alot of cleanup activity after your actual task is over. So, make sure you have taken a sufficient amount of downtime before you start this activity.


Monday, 8 October 2012

Convert existing SharePoint Web Application from Classic mode to Claims mode authentication results in all users getting "Access Denied" error or only view rights of the site

Scenario -
I had an existing SharePoint site that I had created with Classic mode authentication (not a good idea!) and due to certain requirements which needed to be implemented in this site I had to convert the site to Claims based authentication. Though I do not "claim" to be an expert in configuring "Claims" authentication I was aware of the simple process of converting Classic mode authentication to Claims mode.

As is true in most cases, I had commitments to meet and converting the site to Claims mode seemed an easy bit and was at the bottom of my priorities. However, after setting up most pieces of my site (which had anonymous access enabled, by the way) when I converted my site to claims mode I was surprised to see that I could no longer access my site with full privileges except with "System Account". Luckily, since I had anonymous access I was able to atleast browse the site with my other admin users and what I saw is that the user names appeared as "i:0#.w|domain\username". With the System Account I checked for the permissions of the site and the permissions were as earlier, nothing had changed. But, still no access.

Solution -
Please take a backup of your web application before running any of these scripts (it is a good idea to take a backup before running any major Powershell script) as it atleast helped me save face.

First of all below is the powershell script to convert classic mode site to claims mode

$webapp = Get-SPWebApplication -Identity "http://serverURL"
$webapp.UseClaimsAuthentication = $true
$webapp.Update()

As mentioned above after running this script access for my users was altered (removed, rather). Here is what you need to do in addition. But make sure you have your backup ready. The script is as follows -

$webapp = Get-SPWebApplication -Identity "http://serverURL"
$webapp.MigrateUsers($true)

Thats it! Seems pretty simple but it took me around 10 hours of searching before I reached this solution (makes me feel pretty dumb if you reached here in 5 minutes).

Caution! Caution! Caution! -
OK! There was a reason I asked you to have a backup before running scripts. This is what happens when you run the above mentioned scripts:

On executing the first script (to enable claims authentication) the SharePoint Content Database is made ready for claims based authentication but the already existing site users, who in my case were windows users, are not "migrated" to be understood by claims authentication. But SharePoint assumes all users to be claim users and renders them so. Therefore, a normal windows user - "Domain\UserName" appears as "i:0#.w|Domain\UserName". Furthermore, it uses the username in this same format to check for its permissions but does not find a matching entry for the user as the database has windows users - "Domain\UserName". So, the site will give you an access denied or, in my case, anonymous access privileges.

Note that the System Account will work since it's "Domain\UserName" is never used and System Account is a keyword used by SharePoint for your application pool identity. Therefore, it remains unaffected.

To overcome this situation we use the second script to "migrate" the users. MigrateUser($true) will convert all user accounts to claims format. After running this script user accounts are converted in the database to claims format, therefore, user names are read correctly by SharePoint, therefore, permissions for users are associated correclty by SharePoint and therefore, the site permissions work correctly.

Something very important to note here is that ideally, MigrateUser($false) should convert the user names back from claims format to the normal format, but it does not do so. This script will throw an exception and no change will be made to the database - so once you are in claim mode you cannot go back. Please refer this post to revert from claim mode to normal mode. Also note that these scripts are running on Web Applications so they will affect all site collections in that web application

Lessons learnt - I feel, that if you are creating a new web application in SharePoint 2010 always use Claims Mode Authentication as it gives you flexibility and you can avoid wasting your time on "migrating" users back and forth. Probably that is the reason why SharePoint 2013 has done away with Classic mode authentication and has only Claims-based Authentication.

Friday, 1 June 2012

SharePoint on Android/iOS Tablets

The tablet market is expanding by every passing day and honestly, the experience it has created for users is "Amazing". Tablets are here to stay and we have to adapt to this new device as soon as possible.

Being involved with SharePoint and sharing views of many SharePoint professionals, I think we have to start making SharePoint "Tablet-friendly". You would argue that SharePoint being a server-side technology, hosted on a web server can be browsed using the web browsers available in these tablets.That is very correct, but a SharePoint site browsed through a portable device gives very limited capabilities. Customers expect to leverage SharePoint to fully use the tablet experience. That is what will make them fully enjoy SharePoint's power.

There are various applications already available in the stores of Apple and Android powered tablets that can interact seamlessly with SharePoint and give users a rich experience. I have listed some of them below:

  1. Formotus
  2. SharePlus
  3. Mobile Entree
They offer quite different range of capabilities.

Also, you can create your own custom application using the following platforms:
  1. Phone Gap - It is HTML 5 based and uses HTML, JavaScript for application creation
  2. Mono - Makes the .NET libraries available over multiple platforms.

Monday, 21 May 2012

Moving documents from one document library to another maintaining versions - SharePoint 2010


Hear is a simple task - Move documents from one library to another in SharePoint 2010 Document Library. Sounds simple! You can use "send to another location", "explorer view" etc. etc. But let me slightly complicate things here -

Move documents from one library to another in SharePoint 2010 maintaining all versions of the document in the new library.

Now, there is an understood pre-condition associated with this task that both libraries should have versioning enabled to the same level (minor or major).

What I found was that, when we use "send to another location" or any other OOB method to transfer the document from one location to another, versions are not maintained. They are simply forgotten. Reason for this is simple - at the new location, even though versioning is enabled, the transferred (moved) document is the very first version. In simple words, versioning is initiated at the new location only after the document is created there.

But as usual this was something I did not expect, because all my client asked is to move documents from location A to B and I very confidently agreed to do it in a few minutes time. And as a P.S. the client added that documents have versions and versions will be required at the new location. I thought - "That should not be a problem??"

Turned out I was wrong. I panicked and the first thing came to my mind was "custom code" and the pain it would cause to write all those lines, build, debug, test; build, debug, test; build, debug, test... you get the point.

But then, a little bit of researching gave me this quick solution -

All you need to do is open both locations (document libraries) in explorer view and cut and paste the files to the new location. Note that -
  1. Copy and paste will not carry your versions,
  2. Both location should have versioning enabled and
  3. Both libraries should have the same template i.e. document library --> document library or form library --> form libary and so on.
Really neat trick and saved a lot of my time. Huh! Can spend some time playing angry birds now!

Friday, 11 May 2012

"I cannot delete this column from my list??" - Well that must be a SharePoint 2010 Peristent column

If  you are viewing this blog post I assume you have not had a very good day at work today! Here's a look at what happened to me -

I recently ran into a problem where one of my users added a site column called "Target Folder" to their SharePoint list and later realized that that column was not required. So the user wanted to delete the "Target Folder" column. That is the most basic SharePoint task that is there to be done and so I wondered that why is this user coming to me for something so trivial.

Alas! Everything in SharePoint is not what it seems. I went to the list settings clicked on the column and I could not find the delete button in fact I could not find any means to edit that column. What happened here? I checked some other columns (Had my farm gone crazy?) No! Every other column in that list (or for that matter in the site) seemed absolutely fine.

After a few hours of digging here and there I turned to Master Google and I was enlightened!

There are a set of site columns which are Persistent site columns and once added to a list these columns cannot be modified or deleted (through the SharePoint UI). Also, if you add these site columns to a custom site content type you will not be able to delete the site content type as well. On attempting to delete the site content type you will get an error stating - "The content type is in use and cannot be deleted" even though you have not used the content type anywhere.

Here is a list of site columns which are persistent:

  1. Active
  2. Aliases
  3. Article Date
  4. Byline
  5. Contact
  6. Contact E-Mail Address
  7. Contact Name
  8. Contact Picture
  9. Custom Router
  10. Image Caption
  11. Page Content
  12. Page Icon
  13. Page Image
  14. Priority
  15. Properties used in Conditions
  16. Property for Automatic Folder Creation
  17. Rollup Image
  18. Route To External Location
  19. Rule Name
  20. Scheduling End Date
  21. Scheduling Start Date
  22. Submission Content Type
  23. Summary Links
  24. Summary Links 2
  25. Target Audiences
  26. Target Folder
  27. Target Library
  28. Target Path
Be very sure before adding these columns to your list or content type.

To delete these site columns from your list you will need to do so by using PowerShell commands as follows:

$web = Get-SPWeb (Your site URL)
$list = $web.Lists[(Your List Name)]
$field = $list.Fields[(Your Column Name)]
$field.AllowDeletion = “true”
$field.Sealed = “false”
$field.Delete()
$list.Update()
$web.Dispose()

And.. I hope the rest of your day (if left) is nice!

There's a BUG! There's a BUG!! There's a BUG in the Discussion Board

This is something fishy!
Recently I was working with discussion boards in MOSS 2007. All seemed well. I had to create a simple discussion board with approval. "No big deal!", "That's non-IT stuff if you use SharePoint!"....... If this is what you feel you are in for a BIG surprise........ (just like I was :-) )
So I went ahead and created a Discussion Board, went into versioning settings, selected "Require Content Approval" and did a few test runs. Everything seemed to be working fine until I tested with different users.
Problem: User X writes a new post. This post goes for approval to User A. Until User A approves the post this post will not be visible to all the users. So the obvious thing to do is for User A to approve which he does but as soon as User A approves the post, User A's name starts appearing everywhere in the post viz-a-viz in the quoted text section, the picture of the person who started the thread. And poor User X who actally started the post is lost.
Reason: Now, when User A approves the post, he/she becomes the user to last update the post i.e. the modified by column of the post is updated to User A. And it so happens that in the flat or threaded view of a discussion the name of the user who last modified the post is displayed. But in our "content approval" case it sends a very wrong message. If you go back to the subject view to see the entire list of threads you see that the User X is still the creator of the post.
Now what: I had posted a question on MSDN forums, this is the link. I was not too satisfied with the answer. It stated to write an event receiver to update the modified by column of the post back to the created by column..

I wish there was a better way.... 

Copying Multiple User Field from one SharePoint List to another


So once again I landed up in trouble because of the Person or Group field (Multiple Selection). Refer earlier post.
Now, this time what I needed to do is I simply needed to copy a Person or Group field with multiple selection enabled to another such column in another list, through an Event Receiver.
You might think - "Why is he writing an event receiver?? Why can't he just use a simple SPD Workflow??"
But as usual.......... there is a catch!!
I have created a SharePoint site with Forms Based Authentication (FBA). My users no longer come from the Active Directory, they come from an SQL Membership API database.
And.... SPD Workflows run under the OWSTIMER.EXE service not the w3wp.exe service.
(For general information the w3wp service is created by the IIS and is used to handle web requests coming to a web server. The OWSTIMER service is created by the Windows SharePoint Timer Service and is used to execute scheduled jobs of SharePoint.)
So, since the SPD Workflows run under a different service, they cannot read the web.config placed under the IIS Service, therefore, they cannot read the Membership API database settings, therefore, SPD Workflows cannot identify FBA users.
So, I write a little bit of code to perform the task at hand i.e. copying multiple users from one column to another (using event receiver).
But again..... things are not as simple as you think. I write this line of code:
oDestinationList["MultiUser"] = oSourceList["MultiUser"];
here
  • DestinationList is Destination List object
  • SourceList is Source List object, and
  • MultiUser is the name of the field
but this simple line of code doesnt work. It states that the source and destination objects are not of the same type and cannot copy code!!!! Why????? I have no clue!
On googling I found a long procedure for copying multiple user fields: Create a SPFieldUserValueCollection object and append user names in this object etc.etc..... thats too much work...
So, on doing a little bit of research I found that there IS a simpler way of achieving this. Here's the code:
oDestinationList["MultiUser"] = Convert.ToString(oSourceList["MultiUser"]);
and it worked!!!! Hurray!!!!
Really SharePoint is funny!! :)

Send E-Mails to SharePoint Multiple User Field SPD Workflow

I faced a recent problem whilst designing declarative workflows in SPD 2007:
It sounds pretty simple - I needed to send mails using the Workflow to users who were stored in a Person or Group field.
You might think - "What's the big deal in that??".... But here's the catch. The Person or Group field I am referring to allowed multiple user selection.
==Bam==
All hell broke loose. How was this possible??? The Person or Group field just doesn't show up in the Workflow lookup! What do I do? Will I need to write an event receiver? Ohh!!! I didn't want to write code here? It seemed so simple. But wait..... lets try to fool SharePoint.
OK so first I do not allow multiple user selection in my Person or Group field. (You might think what about the already existing records? Data loss! Ya I know.... you might have to do this the hard way - Create a template for your list including content, recreate your list using the template you just created and after finishing all the steps mentioned here add all the entries again..... I told you this was the hard way!)
OK continuing with fooling sharepoint...... now, on preventing multiple user entries my Person or Group field starts appearing in the Workflow lookup for sending mails.
I complete my workflow steps, go back to my list and again allow multiple user selection in my Person or Grop field.
Now lets check whether the workflow is giving any errors.....
No......... no errors! Congratulations! SharePoint has been fooled! (Now can re enter your entries as I had mentioned above)
Happy SharePointing! :)