GITCA, INETA, Microsoft Cloud, Microsoft Community Events, Office 365, SharePoint Online, SharePoint User Group

My “Office 365- SharePoint Online” session at GITCA “24 Hours in the Cloud” Event

[Update 15th April 2011:- This event is re-scheduled to take place on 1st June 2011]

It’s been really a busy year for me so far, I really like indulging into speaking especially when it comes to user groups and communities. GITCA (The Global IT Community Association) on June 1st 2011 will be conducting a 24 hour virtual event “24 hours in the Cloud” focusing on cloud computing. There will be various sessions ranging from Windows Azure to Office 365 (vNext of BPOS). As Office 365 is currently in private beta it’s a great opportunity for many of you to get a closer look into what’s coming up in next from Microsoft.

I am also presenting in this event, my session is “Office 365 – SharePoint Online Overview”. I will be covering the basics of SharePoint Online and dividing my allocated sixty minutes session time into multiple demos with discussion on various features and functionalities of SharePoint Online. I will also touch base on key considerations while making a shift from On-Premise to Online version of SharePoint. It’s a virtual event and all the speakers including me will be available via twitter (mine is @razibinrais) to answer your questions. I will be sharing my session resources (slide deck + session video) after the session right here on this blog post, so stay tuned for that.

 
 

So join in and learn about Microsoft Cloud!

Advertisements
Office 365, Office 365 Grid, SharePoint Online

Microsoft Boosts SharePoint Online with Office 365 Rollout

Couple of month’s back I wrote a brief article on SharePoint Online which is part of Office 365 offering (VNext of BPOS). Following is an excerpt from it and link to the full article.

Microsoft Office 365, which is currently in beta, is the next wave of Microsoft’s online offering containing SharePoint Online, Exchange Online, Lync Online and all of them in the cloud. Office Professional Plus is also available; it provides enhanced productivity while working with various online tools. The following is a quick overview of the productivity and storage availability in the SharePoint Online offering. The details are subject to change as Office 365 become generally available.

If you’re wondering which version of SharePoint is available in Office 365, the good news is its SharePoint Server 2010 but with a few restrictions and limitations. Some of these limitations are due to the fact that currently Office 365 is in beta, but a few of them will likely remain, even after the general availability of Office 365. This makes sense as few features and functionalities of SharePoint Server 2010 will not be feasible for the multitenant approach, which is the hallmark of Microsoft SharePoint Online. As SharePoint online will be made generally available the differences and limitations will be made available by Microsoft. Read Full Article

SharePoint 2010 Products & Technologies

SharePoint 2010: Redirecting User to a Custom Page from Event Receiver

Event receivers in SharePoint allow great flexibility to meet various user requirements, and with each version of SharePoint there are improvements to enhance their usability. One of these added abilities is to redirect user to a custom page (essentially a SharePoint Application Page) while cancelling the event from an event receiver. Let’s consider this scenario: an HR department wants to place a new policy which requires all the users to only upload documents into a document library from 9 a.m. to 5 p.m. Moreover, as this is a new policy, there should be a page that displays the details of the new policy, whenever a user upload is cancelled. The following diagram shows the flow.


Now, a “Item Adding” event receiver will take care of the first part of the requirement, but for the second part there is no OTB support to achieve this in SharePoint 2007. However, SharePoint 2010 provides an excellent way to do this with little bit of an effort. The following steps show the detail of how to achieve this.

First, create a new Visual Studio 2010 Solution and expand “SharePoint 2010” from “Installed Template” and select project type “Event Receiver.” Give a desired name to the solution and project. My previous article covers the event receiver project creation and some required configuration in detail, if you need more help on this topic please refer to it. Also make sure that your project’s target platform is “x64” and target framework is “.NET Framework 3.5” this is a requirement for all SharePoint 2010 projects.

“SharePoint Customization Wizard” will appear. In “type of Event Receiver” select “List Item Events.” From “event source” drop down select “Document Library”. Also select the checkbox for “An item is being added” from the list of available events. See the figure below.


After the project is created, create a page that will be displayed when a document upload is declined. For this, add a layouts folder to the project. You can do it by right clicking on the project and select “SharePoint “Layouts Mapped Folder;” see the figure below.


This will create a layouts folder, actually a subfolder with the same name as project. This layout folder basically corresponds to SharePoint 2010 “Layouts” folder inside the “14” hive (e.g. <DRIVE _LETTER>:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14, where DRIVE_LETTER represents a system drive where SharePoint 2010 is installed and in most cases it’s a C drive)

Right click this subfolder inside the “Layouts” folder, and select “Add, New Item.” This will open a new dialog, select “Application Page,” and use “HRDocumentUplaodMessage.aspx” as a name.


Click “Add.” This will add this application page to the layouts folder. Add the following markup to it as shown below.


In order to add the logic to cancel the document upload, and to display the custom page, add the following code fragment to the “Item Added” event handler.


Replace “[SubfolderName]” with the actual name of the folder created inside “layouts” directory in the previous step by Visual Studio. This is by default set to the same name as of the project.

The code inside the “Item Added” event receiver first make a check that current hour is between 9 am and 5 pm by using “DateTime.Now.Hour” which is in 24 hours format. The value “17” in 24 hour format equates to 5 p.m.

Next, the property “Status” is used. It’s actually of type SPEventRecieverStatus, which in this case sets to “CancelWithRedirectUrl. ” This ensures that event will be canceled and the user will be redirected to a specific URL. The URL is defined and set by another property “RedirectUrl” which takes a relative path to a page which must resides inside “layouts” folder within 14 hive.

Once all of this is done, press F5. This will build and deploy the solution and open up a new browser window with a SharePoint 2010 site.

In order to perform a actual test, make sure that current time on development machine is between 9am to 5pm (you may want to temporary change the current time of your development machine for this test and then revert back to original time later), otherwise logic in the event handler to display custom page will be not executed due to the time interval check .Finally browse to site (if it’s not already opened), and then open any document library and try to upload a document, the custom page should be displayed as shown below. Close the dialog page, and view the document library, notice that the document was not added to the document library. Alternatively when you perform the same upload procedure between 5:01 PM to 8:59 AM your document will be upload successfully.


 

Microsoft Server Faimly & More ....., SharePoint 2010 Products & Technologies, SharePoint User Group

New York City SharePoint Developers UG Post Session Resources

Last Wednesday I delivered a session on “SharePoint 2010 Branding & Customization for Public Facing Sites” at NYC SharePoint Developers User Group at MSFT. As promised following are the links to the session content and related downloads.

Presentation: Watch Online | Download (pptx, ppt, pdf ,xps)

Demo: Master Page + Page Layout + HTML Layout (CSS + Images) | Watch Online | Download Video

Take a look at quick walk through on how to run a demo (for high definition video download it from link above). Make sure you have anonymous user enabled on your web application and site collection otherwise last part where I logged in as anonymous user will not work.

PS: I tried to use Camtasia to record the complete session but it turns out to be a pain as it seems to get stuck for updates and once finally start recording it has some issues with audio (doesn’t sync properly), if I manage to get it working I will upload it as well.

SharePoint 2010 Products & Technologies

Programmatically saving SharePoint Server 2010 barcode Images and values to a File System

While working with Barcodes in SharePoint Server 2010, customer wants to utilize them bit more than just use them as part of list item. Initially they are looking for barcodes (from some 3rd parties) to do the job but when implemented via SharePoint using OTB barcodes policy it was nearly a perfect solution for them, except that they also want the barcodes to be saved (in form of a image) along with barcode number/value (which is essentially also acts as a file name) on a file system. Also they want this to be done externally from SharePoint Interface (although still on the server side) more of like a batch or console app. As it turns out it’s more straightforward than I initially thought it would be, as following code reveals. Basically end result was a console app which runs on demand and gets all the barcode from the specific list and simply save the barcode as image (jpg in this case but it can be in other formats) and give it same name as barcode number/value. Following fragment is actually the core of it.

SaveBarcodes(SPWeb web, string listName, System.Drawing.Imaging.ImageFormat imgFormat)

{

SPList list = web.Lists.TryGetList(listName);

SPQuery query = new SPQuery();

Image img;

     //Just read the fields we need for this task

query.ViewFields = string.Concat(

“<FieldRef Name=’_dlc_BarcodePreview’ />”, “<FieldRef Name=’_dlc_BarcodeImage’ />”, “<FieldRef Name=’_dlc_BarcodeValue’ />”);

query.ViewFieldsOnly = true;

SPListItemCollection listCol = list.GetItems(query);

foreach (SPListItem item in listCol)

{

img = Barcode.GetBarcodeImage(item);

 img.Save(string.Format(“{0}.{1}”, Barcode.GetBarcodeValue(item), imgFormat.ToString()), imgFormat);

 }

}

Please note that you have to add references to “Microsoft.Office.Policy” and “System.Drawing” assemblies to compile the code. Also add namespaces “Microsoft.Office.RecordsManagement.PolicyFeatures” and “System.Drawing.Image” as they will be required.

Following is the final outcome, see the barcodes saved as images and name of the files are same as that of barcode number/value.

Microsoft Server Faimly & More ....., SharePoint 2010 Products & Technologies

How to Use Custom Colors in SharePoint 2010 Status Bar using CSS

The new Status bar in SharePoint 2010 is helpful in putting important information to the user in a more prominent way. By default there are total of four different status colors showing four different priorities as shown in figure below.

For most scenarios these colors and priorities will be enough. But there are scenarios where you will be required to change the colors as per business requirements. In this post you learn how to use custom colors to replace the original colors in status bar using CSS classes.–

Changing Status Background Color using CSS

The background colors for the status are coming from four classes residing inside core4.css files. Following figure shows these classes.

If you dig even deeper you will fill find out the that SharePoint uses class scheme like “s4-status-sN” where N is the status number corresponds to “1: Red, 2:Yellow , 3: Green and 4: Blue”. For example SharePoint will use “s4-status-s2” class for displaying status with Yellow background representing important status.

This can easily be pointed out as shown in figure below where IE8 developer tool bar is used to capture this.

Looking at the above scheming of the classes you might think about adding your own classes with incremental value for “N” that is greater than number four. For example “s4-status-s5to include your custom color, unfortunately this approach will not work. This is mainly because the default JavaScript that changes the status bar color can only use the four default classes. So the quickest way is to change the CSS and update these classes with desired color. Keep in mind that this approach will work but you still limited to total of four colors of status. But this is mainly a no code approach so may work faster and in most cases fulfill the need.

Following is the complete walk through of how to change the status colors using custom CSS, the Visual Studio 2010 project is created to demonstrate end to end scenario and test your work. But this is by no means a requirement, you can skip this and just use the CSS shown in step 9 and it should work. For those of you who want to try complete example following are the steps.

  1. Open a Visual Studio 2010 and create a new SharePoint 2010 Project, select “Empty SharePoint Project” as project type and give it a name “MyCustomStatusColors”. Click “OK” to create the project. See the figure below.

     

     

  2. On the “SharePoint Customization Wizard” type the URL of the SharePoint site which you want to use for deployment & debugging. Select “Deploy as farm solution”, see the figure below. Finally click “Finish”.

     

     

  3. Right Click the project and select “Addà SharePoint “Layouts” Mapped Folder” this will create a new mapped folder named “MyCustomStatusColor” as shown below.

     

     

  4. Right Click “MyCustomStatusColor” folder and select “AddàNew Item”.

     

  5. On the “Add New Item” dialog box select “Web” the installed template and then select “Style Sheet”. Name it “CustomStatusColors.css”, and click “Add”. This is shown in figure below.

 

 

 

 

  1. Open the “core4.css” file located inside “<Drive-Letter>:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTS1033STYLES”. Where “<Drive-Letter>” is the drive where SharePoint is installed (for example “C”).

     

  2. Locate and copy the following classes from “core4.css” file.

     

     

  3. Paste these classes into CSS file “MyCustomStatusColors.css” that you created in Step 5.

     

  4. Change the background, border-color, and color attributes for all the classes as shown in figure below. You can always choose colors of your choice.

     

     

  5. Your work related to CSS customization is done, next you build a very simple SharePoint Application Page with a single HTML button and a drop down which corresponds to status number. On clicking the button a new status message will be added to status bar using SharePoint ECMAScript. It’s a simple way to see the changes in action. We will later use this page in second part for some more advance JavaScript based customizations.

     

  6. Click on “MyCustomStatusColors” folder and select “Add New Item”. On the “Add New Item” dialog select “Application Page”. Name it “CustomStatusColors.aspx”, and click “Add”. This is shown in figure below.

 

 

 

  1. First add a link to the custom “CustomStatusColors.css”, this way classes inside it will override the “core4.css” classes. This is shown in figure below. Make sure you add it under content area with ID “PageHead”

     

     

  2. Before we add the SharePoint ECMA Script code to add new status with desired color note that as we only changed colors through CSS the ECMA Script function does not have knowledge of these custom colors, so in standard SharePoint ECMAScript methods you still need to pass original color names namely “red,yellow,blue,green”, this is just a way it behaves. However as we have changed the colors inside CSS classes these custom colors will correctly appear for the status messages instead of the original colors. For your convenience following table shows this mapping including original color and new colors.

     

Class

Original Color

New Color

s4-status-s1

Red

Lime

s4-status-s2

Yellow

Olive

s4-status-s3

Green

Aqua

s4-status-s4

Blue

Teal

 

  1. Add following script into the “PageHead” content area as shown in figure below.

 

  1. Finally add the following markup into the “Main” content.

     

     

  2. That’s it, press F5 from the Visual Studio to build and deploy the project, this will also open the site in a new browser window so you can test your work.

     

    Note: You must build the project targeting x64 platform. This is the requirement for all SharePoint 2010 projects.

     

  3. On the SharePoint site, type the following URL, replace “SiteURL” with the actual URL of your SharePoint site. This is the site URL that you have used while creating the SharePoint project in Step 2.

     

    http://SiteURL/_layouts/MyCustomStatusColors/CustomStatusColor.aspx

     

  4. On the “CustomStatusColor” page use the drop down to select any status and then click “change status color” button. You will notice a new status message is added each time you click the button and color of the status message is coming from custom CSS. You may want to contrast these colors with the table shown in step 13. Following is the screen shot of all the four status messages with custom color.

 

Lime

Olive

Aqua

 

 

 

Teal

 

 

Although you have applied color of your choice you are still limited to total of four colors at a time, this can be overcome by using java script. Perhaps I will do a write up on that too in a later post.

Uncategorized

Session on Document Management in SharePoint 2010 @Southeast Asia SharePoint Conference 2010

Yesterday at Southeast Asia SharePoint 2010 Conference @ Singapore I presented a session titled “SharePoint 2010 Document Management for Business Users”. The session  focus on business users/power users rather than Dev/IT Pro. Following are the links to the presentations.

View Online

Download  pptx | ppt | xps | pdf

Check out some of the photos below  (Photo Courtesy Kit Kai)

sea 01 sea 02