April 30, 2012

Using HttpContext.GetGlobalResourceObject in webpart development

We found interesting issue during working with global resource files this week.

Problem:
Event if we are using HttpContext.GetGlobalResourceObject, web part was rendering data in English even if site language is other than English!

If we switch to edit mode, it was working sometime, but most of the time it was showing English text.

Root cause:
We tried creating a new application page and placed a webpart there, it was strange that it was working properly in the application page.

We finally found that at the time of reading resources through  HttpContext.GetGlobalResourceObject web part was not aware of the current UICulture

Solution:
Before:

   1:  var strLinkText = HttpContext.GetGlobalResourceObject("file", "key");
After:​

   1:  var strLinkText = HttpContext.GetGlobalResourceObject("file", "key",SPContext.Current.Web.UICulture);

Conclusion
Finally after passing third argument from SPContext.Current.Web.UICulture it worked properly
If you have any questions you can reach out our SharePoint Consulting team here.

April 23, 2012

Creating your first data cube.

SQL Server 2005/2008 comes along with the Business Intelligence Development Studio (also known as BIDS) which is used for creating projects related to analysis services, integration services, report server and report models (used to design reports on client side). In order to get started with BIDS to build your first analysis services project, you need to have the following SQL Server components installed: SQL Server Database Engine SQL Server Analysis Services (SSAS) Business Intelligence Development Studio A good working data warehouse Below are the steps to be followed to create the cube 

Create a new Analysis Services project

For creating a new project in BIDS, you’ll find the Business Intelligence Development Studio (BIDS) in Start > Microsoft SQL Server 2005/2008 folder. Once you’re in the business intelligence development studio, click File > New > Project from where you could create a new Analysis Services Project. Give it any name you like and click on ok. 

Define a data source

To define a data source, you'll use the Data Source Wizard. You can launch this wizard by right-clicking on the Data Sources folder in your new Analysis Services project. The wizard will walk you through the process of defining a data source for your cube, including choosing a connection and specifying security credentials to be used to connect to the data source. 

Defining a Data Source View

A data source view is a persistent set of tables from a data source that supply the data for a particular cube. BIDS also includes a wizard for creating data source views, which you can invoke by right-clicking on the Data Source Views folder in Solution Explorer. You can select from existing tables and set relations between them or enter in your own statements using “Edit Named Query”.
Now you can move further either creating Cube using Cube Wizard which automatically creates Dimensions to be used in the cube or by creating a Dimensions and using it in the Cube.

Creating Dimensions

BIDS also provides wizard for creating dimensions. It helps in defining the key columns and attributes to be in used within a cube. 

Creating Cubes

Cube wizard appears within BIDS for creating cubes where in measurement group tables are to be defined. Here option to either select from existing dimensions or create new dimensions is provided.

Deploying and Processing a Cube

To deploy the cube you just created, select Build > Deploy. This will deploy the cube to your local Analysis Server, and also process the cube, building the aggregates for you. BIDS will open the Deployment Progress window which will keep you informed during deployment and processing.

If you have any questions you can reach out our SharePoint Consulting team here.

Best Practice: Maintaining scripts in your SharePoint project


Introduction

Branding is the most important part of any SharePoint project. If you are planning to deliver branding in your release, you have to make sure your developer team is proactive to deliver quality branding from early stage of the project. In most of the branding project, jQuery and JavaScript becomes must-have part. Here, we will discuss practices that can be followed to ensure quality deliverables.

Practice
  • Manage script files
    From the very starting stage of your project, split your all JavaScript code in three files.
    • jQuery.min.js - This will contain jQuery reference and should be reference first in order.
    • jQuery.plugins.js - This should contain all custom plugins we used in it.
    • ProjectName.js - This should contain all your custom code written to get your project pages work properly.
  • Choosing plugins for your project
    • Download plugin bundle to your local computer.
    • Generally plugin will contain sample html files, jQuery and plugin script files.
    • First thing to check is jQuery version you are using in your project and the one which is used in the plugin.
    • If they are different, replace their jQuery.min.js with the one we are using.
    • Properly test the sample provided in plugin in all browsers you are planning to support.
    • Once browser and version compatibility matches paste plugin's min.js at end of jQuery.plugins.js file.
    • Implement plugin specific mark up wherever applicable.
    • Always use projectName.js to initialize plugin.
    • Repeat above process when you choose to add any jQuery plugin
  • Resolving CONFLICTS!
    Another challenging part is, jQuery ready not working or custom plugin you are using is disturbing your site's CSS. Here are thoughts on the same:
    • Always use _spBodyOnLoadFunctionNames.Push("yourFunctionName") to initialize your scripts in page load.
    • Always use only necessary CSS from what plugin CSS has provided and prefix class or ID in CSS as application. For example if a generic class .clear is used and you are calling plugin using $('#news') you should replace that with #news .clear. Do this for all CSS you include for the class.
Final thoughts
Here we've pointed out some of the best practices. Like this post? You would like to add/correct something? please provide your feedback on the same. 

If you have any questions you can reach out our SharePoint Consulting team here.