Thursday, December 20, 2018

Resize images in Azure Blob


Image Optimization 

The loading speed of a web page is based on the size of all the components required to render the page including images, HTML, JavaScript, and CSS. By optimizing the images with compression and resizing, we can offset the effects of very large images and increase the performance. Image rendition in SharePoint is a capability which helps to optimize images in a site by having the same image but in different sizes. This will enhance the user experience as well when browsing the site from different devices.

There are scenarios we can use Azure blob storage to store images and retrieve them from there. In such a situation, the developers have to implement a custom solution to handle the image rendition for Azure images.

Options to implement an Image Resizer

1. Using Nuget package

A Nuget package is available called ‘Image Resizer’, which is an open source ASP.NET library that handles the image processing dynamically. Based on the parameters defined in the URL, it will handle the image transformation and provide the resized version of the image in run time.

For example:  If the image source url is defined as <ImageUrl>? width=108&height=70, this will return the resized image for given dimensions.

Steps to follow:
     1. Create an Asp.Net web application and install all the NuGet packages for Image Resizer and Azure plugins.
            2. Configure the application to connect to Blob storage as an image processing platform.
            3. Create a new Azure Web App to deploy the solution.
            4. Publish the application to Azure Web App.

       2. Azure Blob Trigger Function

     Create an Azure Blob Trigger Function/Web job which will be executed whenever a new image is added to the blob storage and handle the resizing of the image in the background. The result image with the reduced size can be saved to a different container with the same name.

There are some extensions available for Asp.Net and Azure:
     ImageProcessor.Web
            ImageResizer.WebConfig
         




Tuesday, December 4, 2018

How to design SharePoint Taxonomy

In general, SharePoint taxonomy refers to a catalog of objects in SharePoint environment or the process of categorizing or classifying objects based on a taxonomic scheme. The ultimate goal of the taxonomy development process is to obtain a comprehensive schema that logically organizes the related objects in a hierarchical structure across a SharePoint implementation.

There are two ways to design and roll out a taxonomy for an organization.

1. TOP-DOWN DESIGN

2. BOTTOM-UP DESIGN


1. TOP-DOWN DESIGN

The obvious way to implement and take advantage of structured taxonomy would be to implement a company-wide taxonomy from day one. This requires that we develop metadata and content types plan across the whole organization before start using the taxonomy. While great in theory, this is very challenging in practice. Development of company-wide taxonomy requires company-wide participation. That means that all departments need to be involved in the development of company metadata and content type strategy. The challenge with this approach is quite obvious. Getting everyone together is a challenge by itself. Moreover, the whole concept of metadata and content types is almost always new to most in early stages of SharePoint implementation. So asking departments to categorize their content, develop metadata tags and content types might seem like learning Greek to many.


2. BOTTOM-UP DESIGN

he other way to develop company taxonomy in SharePoint is to use bottom-up approach. Essentially what that means is that we develop your taxonomy as we develop your sites and migrate content to SharePoint. As we develop the sites and document libraries, we can create metadata. Some metadata will be local or department specific (i.e. HR document types), while some will be company-wide/global (i.e. Department Names). Both might end up in the Term Store and will be the first steps to company taxonomy. As we continue to roll out other sites (say Finance, IT or project sites), we might take advantage of the company-wide/global metadata already created previously. And so on. At the end of the day, we will end up with your company-specific taxonomy that can be used and reused by various departments and types of sites.


Thursday, November 15, 2018

All about SharePoint Online Content Type Hub

What is SharePoint Online Content Type hub?

A Centralized location, a site collection where we can create all the site columns and Content Types so that these Content Types can be used across all other site collections. Content type hub in SharePoint Online is already created and fully functional. Every SharePoint Online tenant has a content type hub pre-built, we just need to use it. It is actually hidden through Admin Center and can be accessed with the generic URL:

https://teanant.name.com/sites/contenttypehub/

The content type syndication hub feature is already activated under this site collection. 

Publish a content type
On a content type hub that publishes content types to other site collections, we can publish, republish, or unpublish content types centrally.
After a new content type is created under content type hub, Publish option is there on the settings page to make the content type available to use for other site collections. 
Next, it is required to go to the Site Collection Administration on the Site Collection where we wish to use the new Content Type (Site Settings > [Site Collection Administration] Content Type Publishing), and enable the checkbox to “Refresh all published content types on next update”. 
This will update all published Content Types the next time the Content Type Subscriber timer job runs.  After the update, this Site Collection is subscribed to the new content type and it will be listed under the list of site content types.
Content Type Hub - Pros & Cons
Pros
1. create, configure, and maintain your custom content types within one central location. 
2. Re-usability
Cons
1. The timer job runs once every hour and we have no idea when it happens. 
2. Unnecessary content types deployed to all the site collections, creates confusion for SharePoint site owners.
2. Synchronization issues. Ex:  When a content type is retracted from the hub and deleted it, the content type is still being deployed to newly created site collections. 
4. The recommendation from Microsoft for the limit of Content types in the hub is a very less 

Tuesday, October 30, 2018

Best Practices for Document Management in SharePoint


When it comes to organizing documents – there are definitely lots of options that exist – it all depends on your particular business need. However, I would like to share what I think are the top five best practices that would be true for any scenario or SharePoint document library. I expect my audience to have Administrative privileges to the site to take advantage of most of the items below. So here it goes:

1. USE META TAGS/DATA COLUMNS TO TAG DOCUMENTS, RATHER THAN RECREATING FOLDERS

Having folders is not a good idea when it comes to document management in SharePoint.

2. USE CONTENT TYPES FOR DYNAMIC META TAGGING

Go one step further and take advantage of Content Type functionality. It allows you to set dynamic properties/meta tags depending on the document you upload (i.e. if you are uploading Meeting Minutes from last project meeting – you might want to tag them differently comparing to, say, PowerPoint presentation you received from last week’s vendor presentation.

3. SETUP AN ALERT FOR A DOCUMENT LIBRARY

Alerts can be configured at a library and document level and will notify the user if files in the library have been deleted or changed by someone else. Alert can be setup by any user, even those without admin rights.

4. USE VERSION CONTROL/CHECK-OUT FEATURES ONLY IF USERS REQUIRE IT

Versioning and document check-in is cool, but do you really need it? Yes, versioning allows you to restore previous versions of the document and check-out feature prevents from accidentally modifying same doc by 2 people at same time, but does Business actually need it? The features demand strict adherence and discipline (i.e. same file names) within organization. Unless you are using document repository as records management tool, you might want to think twice about this. If all your users need is some place to store files, you can easily get away from additional frustration.

5. CREATE VIEWS

Once you setup your Meta tags, you can do wonders with views! Create all sorts of views (make sure to make them public) and use filter/sort/group function to display what you want. Views can also help manage space on a page. If you have lots of lists and libraries on a page and want to fit it all, make sure to use “simplified’ view with just few columns to capture “important” data. Users can then use rest of views to display other pieces of information.

Sunday, March 26, 2017

SharePoint : Error - Custom Field Type has not been installed properly

Some days ago, while I was deploying a release package to the UAT server, I had to face a strange issue. There was a release step in the release note to execute a PowerShell script after installing the solution, in order to update some of the metadata fields in a Document Library. 

There is a field within the document library columns which has been created using a custom field type, which is deployed through a farm solution. The given farm solution had web application scoped resources therefore it was deployed only to the Web Front End server and not globally deployed. 

Now the issue was, when executing the PowerShell script to update some metadata in the document library items, the values already existent in the above custom field had got emptied although this field was not touched through the script. 

After digging into the problem, I found that the root cause for this problem was because I was executed the script within the Application server. The farm solution had only installed the definition of the custom field type to the WFE server. This can happen to the feature definitions as well. Therefore, when retrieving the list item object through PowerShell code, the value of the custom field was not included. That's because the field type cannot be retrieved when trying to access it from the APPs server. As the list item object does not include this custom field property, it had emptied while updating list item back. 
Finally, I changed the server and ran the script in the WFE server and everything worked properly. 
Therefore, as a best practice and also as recommended, we have to keep in mind to execute these kind of PowerShell scripts inside the WFE server when the multi server architecture is used.

  

Wednesday, February 8, 2017

Folders in SharePoint - is it a bad idea?

Following are some compelling reasons on why folders in SharePoint should be avoided. The list is geared more towards end-users and folder proponents and could be used as a business case on why document library should be setup using meta-data. So here it goes:

1. USABILITY

Nested folder structure is only known to the person who created it. Also, too many sub-folders tend to “hide” things.

2. URL LENGTH LIMITATION

SharePoint adds all folder and sub-folder names to URL. Overall URL length is limited to around 260 characters. You are out of luck if you create too many sub-folders.

3. FILE URL

Moving file from one folder to another means change of file URL.

4. SECURITY

Maintaining Security by folders in SharePoint is an administrative nightmare. 

5. USER EXPERIENCE

User Experience (navigation, finding the documents) just stinks with folders

6. FILE DUPLICATION

With folders you can deposit multiple copies of same file into different locations – not a good thing when you try to organize documents and data in the first place!

7. ONE LONELY VIEW

There is another reason NOT to user folders. With folders, you get one view: the folder view. Using metadata, you can create unlimited number of views by whatever properties you have setup (i.e. organize documents by date, by customer, by project, etc.) So the document browsing experience is much better-off.

8. CAN’T SORT & FILTER

Since your files are buried in the folders, you can’t really benefit from sorting and filtering capabilities of document library headers (unless of course you are just sorting and filtering in the particular folder).

9. CHANGE IS HARD

It’s hard to change folder structure, while changing metadata is easy.

10. LOST DOCUMENTS

You can “lose” documents when placed in the wrong folder. Additionally, Also, too many sub-folders tend to hide things, making it impossible or too time-consuming for users to find a particular document.

11. NAVIGATION

When you are in a particular sub-folder, there is no way to tell in which folder you are at any given time, and no easy way to navigate to the parent folder (there is no breadcrumb on folder navigation menu available)

12. COST

If you are essentially recreating nested folders you had on file share, by using SharePoint, you have got yourself one expensive file share.

Tuesday, February 7, 2017

SharePoint: Error : Workflow definition Id is undefined (returns 0)

Sometime back we developed a SharePoint 2013 Visual Studio Workflow to one of our clients. The workflow association to a document library was also implemented in the code inside a feature activation. Recently, I was deploying this solution to a new site collection in my development environment and I got an exception while activating the workflow association feature. 

The issue was because the workflow definition id returns 0 when retrieving the workflow definitions deployed to the site.

WorkflowServicesManager workflowServicesManager = new WorkflowServicesManager(currentWeb);
WorkflowDeploymentService workflowDeploymentService =                            workflowServicesManager.GetWorkflowDeploymentService();

 WorkflowDefinitionCollection workflowDefinitions = workflowDeploymentService.EnumerateDefinitions(true);

foreach (WorkflowDefinition workflowDefinition in workflowDefinitions)
            {
                if (workflowDefinition.DisplayName.Equals("Document Workflow"))
                {                    
                    WorkflowSubscription workflowSubscription = new WorkflowSubscription();
                    workflowSubscription.DefinitionId = workflowDefinition.Id;
                    workflowSubscription.Enabled = true;
                    workflowSubscription.EventSourceId = documentLibraryList.ID;
                    workflowSubscription.Name = workflowDefinition.DisplayName;

                    workflowSubscription.EventTypes = eventTypes;
                    workflowSubscription.SetProperty(
                        OnlineSubmissionWorkflowAssociationFeatureEventReceiver.TaskListId,
                        documentWorkflowTaskList.ID.ToString());
                    workflowSubscription.SetProperty(
                        OnlineSubmissionWorkflowAssociationFeatureEventReceiver.HistoryListId,
                        workflowHistoryList.ID.ToString());
                    workflowSubscription.SetProperty(
                        OnlineSubmissionWorkflowAssociationFeatureEventReceiver.FormData,
                        string.Empty);

WorkflowSubscriptionService workflowSubscriptionService = workflowServicesManager.GetWorkflowSubscriptionService();

  if (workflowSubscriptionService.EnumerateSubscriptionsByList(documentLibraryList.ID).Count == 0)
   {
        workflowSubscriptionService.PublishSubscriptionForList(workflowSubscription, documentLibraryList.ID);
     }

  }
}

As the workflow definition Id is not defined, the workflow subscription Id is also becomes undefined. Therefore, the exception was thrown when trying to publish the subscription without a definition id, to the list.

Following are the steps followed to resolve this issue.


  • Activate the Workflow Task Content Type site feature if not already activated.
  • Activate the “Workflow service store” hidden feature. 

            In the SharePoint 2013 Management shell, run  the command, 
          Enable-SPFeature -Identity "workflowservicestore" -url "<sub site url>"

  • Make sure the Service Bus Gateway, Service Bus Message Broker and also Workflow Manager Backend services are up and running in the WFE server. Also, all these services should be logged on using the same service account.  Restart the services. 
  • Go to IIS Manager and check whether the Workflow Management Pool is running under Application Pools using the same service account. Restart the application pool.
Now the issue should be gone away. 

  

Tuesday, December 20, 2016

Use of SharePoint Calculated Columns

Why Calculated columns important?

Assume we need to send out an automated company-wide birthday greeting email whenever it was an employee's birthday. The option that will come to our mind suddenly :

1.  Use SharePoint Designer to create a workflow that sends an email.
2.  Run a timer job every night.  This timer job would pull all employees that have a birthday that day from a SharePoint list, then trigger the workflow for each birthday found.

Then we may have one requirement that, in the body of the email for it to say “Happy Birthday to [employee name] on October 2nd” for example.  But if it’s the 1st, then there should be an “st” on the end of the birthday day.  Or “th” if it’s the 4th, and so on.

This is where the Calculated columns come into play.

Calculated Columns to the Rescue

We can create a few calculated columns to handle the day suffix, and well as displaying the day and the name of the birthday month, as below.

Birthday Month Name

It’s pretty easy to derive the name of the month from a particular date field using a simple formula.  The second parameter passed to the TEXT function is what tells it how to format the month, in this case it is formatting as the full month name, for example, October.

=TEXT([Date of Birth],”mmmm”)

Birthday Day

Very similar to the first example.  We will just grab the day from the date using the DAY function.


=DAY([Date of Birth])

Birthday Day Suffix

This is the tricky one.  We can use a combination of nested IF functions and the OR function in order to achieve the desired result.  Since a formula for SharePoint calculated columns need to be written in one line of code, we can’t do traditional if-then-else statements.  However, we can use nested IF statements, but if you have a lot of “else” clauses, it can get very messy.

=IF(OR([Birthday Day]=”11″,[Birthday Day]=”12″,[Birthday Day]=”13″),”th”,(IF(RIGHT([Birthday Day])=”1″,”st”,(IF(RIGHT([Birthday Day])=”2″,”nd”,(IF(RIGHT([Birthday Day])=”3″,”rd”,”th”)))))))

To create a calculated column, simply go into the list’s List Settings page and add a new column.  Then choose Calculated for the column type and fill out the Formula field.

Sunday, December 4, 2016

List all Site Collections in a Farm and show in which Content DBs they are stored


In some cases, for example when analyzing or optimizing the distribution of Site Collections in a SharePoint farm, it may be helpful to see which Site Collections are stored in which Content Databases.
This can easily achieved by using this SharePoint Management Shell cmdlet:


Get-SPSite -Limit All | Select Url,ContentDatabase | Format-Table -Wrap -AutoSize > D:\Output\ShowAllSCs.txt

Alternatively it may also be helpful to dispaly all Site Collections in a certain Content Database:

Get-SPSite -Limit All -ContentDatabase | Format-Table -Wrap -AutoSize > D:\Output\ShowSCsInContentDB.txt

Or display all Site Collections in a certain Web Application:

Get-SPWebApplication https://webapplication.domain.com | Get-SPSite -Limit All | Select Url,ContentDatabase | Format-Table -Wrap -AutoSize > D:\Output\ShowAllSCsInWA.txt

Friday, October 21, 2016

Versioning in SharePoint

 In my opinion, versioning in SharePoint is one of its strongest features. It allows for tracking the activity of any item (document, event, task, etc.) and following the audit trail. In this post, I would like to highlight the most important features of versioning and how it can assist you, the end user, with your daily routine. Let’s first look at what versioning is and how it works.

Any time you change a document in a document library or edit any list item (in a custom list, calendar, task list, etc.) – a new version is created. Any change is recorded, whether it is a physical change to the document or just a metadata change. If you just view an item or a document by clicking on it – the new version is not created, it is only created when you actually change something.

WHAT ARE THE MAJOR BENEFITS OF VERSIONING?

1. Ability to audit the history of an item

Version history allows you to retrace the history of an item or a document, since the date and time it was first created till present. If it is a document you are checking, you can see all the changes taking place (physical changes to the document or metadata). If it is an item, like a task or calendar event, you can see the metadata changes made, who made them and when.

2. Ability to track metadata changes

Any metadata changes are perfectly visible in the version history log from above. Say, you have enabled versioning on an Issue Tracking to track help desk tickets. With version history, you can easily see what has happened to the ticket from the time it was submitted to present.

3. Ability to track content changes

If you enable versioning on a document library, you can access any previous versions of the document just by clicking on a previous version link.

4. Ability to restore previous versions

You can also restore older versions if need be. Say you created an important document and then you boss decided to edit and made changes that make no sense. No problem at all. Just click on a drop-down next to the version you would like to restore and click Restore. It will take this version and create a new one for you, making it the latest and greatest.

Thursday, September 15, 2016

Document Sets - New Feature in SharePoint

WHAT IS A DOCUMENT SET?

Document Set is a special Content Type. To explain in basic terms, Document Set is a folder with metadata. Except, this folder can have metadata assigned to it. And the documents you put inside of that folder can also have metadata assigned to them. Awesome!

WHAT MAKES DOCUMENT SETS SPECIAL?

In addition to being able to have metadata combined with folders, document sets have these special and unique features that make them standout from other document management methods.

1. Ability to inherit metadata
You can set the Document Set such that any files uploaded to the Document Set (folder) will inherit the metadata from that folder.

2. Unique permission for each document set
You can also assign unique permission to each document set. You can do the same with regular folders, but the user experience is much better with document sets.

3. Ability to search across the document sets
All the document sets (folders) you create reside in a single library. That means that you can easily search across document sets since you will essentially be searching in a single document library.

DOCUMENT SET LIMITATIONS

1. It is all about documents

It is a limitation by default. But If you are thinking of using document sets to manage small projects, all you have on a welcome page is a document set. While you can add other web parts to the welcome page, they will be common to all document sets (in other words, you cannot have each welcome page contain its own task list or calendar for example).

2. Document Library can get really large
Say you configured a document library to house client data and are using document sets for it. With time, this library might get really large, impacting performance and ability to find stuff.

3. Metadata sync
If you decide to sync the document library with document sets to your desktop (link) – you would loose the metadata when you try to access the files on your PC. Metadata will stay in SharePoint, but will not get copied onto your computer.