Welcome

Sharepoint lead is a place where you can read about interesting topics related to sharepoint, and you can also post comments and suggessions.
Showing posts with label sharepoint 2010 development. Show all posts
Showing posts with label sharepoint 2010 development. Show all posts

Monday, July 2, 2012

SMTP4DEV: Your sharepoint 2010 out going email server for development farm

If you are having standalone sharepoint 2010 development farm on window7 64bit, and looking for good option,  SMTP4DEV. It is a free tool. You will need around 10mins and then you can start receiving emails from sharepoint farm! Here are quick steps:

  1. Download  SMTP4DEV from it's codeplex project site, I prefer standalone exe but you can download installer as well.
  2. If you like to use some custom local domain, click on options and set up some local domain like local.machinename.com. Create host entry pointing to 127.0.0.1
  3. By completing these many steps you can now send emails through  SMTP4DEV by any url ending in @local.machinename.com
  4. Go to sharepoint central administration > System settings > setup outgoing email server.
  5. set local.machinename.com as server, and provide any email ending in @local.machinename.com 
  6. Save your settings
After these minimum set of configuration you will be able to start sending emails. Beauty of SMTP4DEV is:
  1. It will show you notification that new email is sent
  2. It will show you all emails sent from the smtp in UI without actually sending it
  3. You can inspect email
  4. You can view email (in email client that you set default)
So, in conclusion, it is a best choice KISS kind of solution for your sharepoint 2010 development farm's outgoing SMTP server.




Sharepoint 2010: TryGetList vs GetList

As a developer, you will say GetList can throw exception but TryGetList will not. It is actually confusing because TryGetList looks for listTitle and returns null if list is not available at expected location. GetList will expect listUrl and can throw FileNotFoundException or ArgumentException if list is not present at expected location or relative/absolute url of list is invalid relatively. Another biggest difference is they belong to different class!


Apart from all those technical details, I noticed that many sharepoint administrators likes to start with a simple list/library name and eventually change it to make it as close as possible to what they do. That will make list/library url and their names different. Here comes the actual problem. If you are actually using list/library names in your code, it will no longer work. OR we can say you are not allowing sharepoint administrators to change name of list/library that they have created. 


By using GetList you are actually giving them flexibility to use whatever name they like to use, as far as they are not changing url or list/library code will still work.


In conclusion, it really depends on requirements how you are going to deal with the situation but it is good to keep in mind that you can use GetUrl function in your code to allow sharepoint administrators to change their names without worrying about breaking functionality.







Monday, May 28, 2012

CAML Designer: Try it now!

When you want to design/test your caml query, most of the time uses U2U CAML Query builder. Sometimes you get problem with connection but most of the time, it was working fine for most of the needs.

Recently, I tried CAML Designer which is really nice tool to try as alternative. WPF UI experience with many additional features may impress you to switch to this new tool.

Let me know your experience while evaluating

Wednesday, May 16, 2012

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
  1. Manage script files
    From the very starting stage of your project, split your all javascript code in three files.
    1. jQuery.min.js - This will contain jQuery reference and should be reference first in order.
    2. jQuery.plugins.js - This should contain all custom plugins we used in it.
    3. ProjectName.js - This hsould contain all your custom code written to get your project pages work properly​​
  2. ​Choosing plugins for your project
    1. Download plugin bundle to your local computer
    2. Generally plugin will contain sample html files, jQuery and plugin script files.
    3. First thing to check is, jQuery version you are using in your project and the one which is used in plugin
    4. If they are different, replace their jQuery.min.js with the one we are using
    5. Properly test the sample provided in plugin in all browsers you are planning to support
    6. Once browser and version compability matches paste plugin's min.js at end of jQuery.plugins.js file.
    7. Implement plugin specific mark up wherever applicable
    8. Always use projectName.js to initialize plugin.
    9. Repeat above process when you choose to add any jQuery plugin
  3. 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
    1. Aways use _spBodyOnLoadFunctionNames.Push("yourFunctionName") to init your scripts in page load.
    2. Always use only necessary css from what plugin css has proviced 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 I pointed out some of the best practices. Like this post? You like to add/correct something? please provide your feedback on the same.

Monday, May 14, 2012

using HttpContext.GetGlobalResourceObject in webpart development


I 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
​