Wednesday, April 22, 2015

SPWeb CacheAllSchema

Recently , I found an interesting the property of SPWeb class's CacheAllSchema on preparing for my exam 70-489,SharePoint 2013 Core Solution.

In SharePoint 2010, this is an little angel to cache the SharePoint files (Maby be the site template or definition stuffs ) on the client computer and subsequent request to server and then server trip will be reduced considerably.

Soon I am going to dig further on this property and update this post.

On continuous improvement on SharePoint technology, BranchCache, Windows Fabric App cache and Load balancing features were introduced.

Thursday, March 26, 2015

The Evolution of SharePoint Server


Wow !  see the Evolution of SharePoint Server since 2001 to till now. I am so lucky to part of this evolution since MOSS 2007 . I used to work  with the  MOSS 2007 team wherever they need fix on using .NET.

Now I am full time developer on SharePoint technologies.

I really happy to see the unopened software CD pack image from the "Bill Baer" tweet.


Tuesday, March 17, 2015

CSOM LookUp Field value retrieval

Here is a simple code snippet to retrieve the LookUp value from the List Item.
You need to casting the retrieved item as FieldLookupValue to process further.

 ClientContext ctx = new ClientContext("http://win-gc3f02d6lkq/sites/apps");
            var list = ctx.Web.Lists.GetByTitle("Cities");
            CamlQuery query = new CamlQuery();
            query.ViewXml ="";
            ListItemCollection items = list.GetItems(query);
            ctx.Load(items);
            ctx.ExecuteQuery();
            foreach(var item in items)
            {
                var lookUpId = item ["Country"] as FieldLookupValue;
                Console.WriteLine(item["Title"].ToString() + "--" + lookUpId.LookupValue);
            }
            Console.ReadLine();
This will lists the city name along with country field that has been used as lookup column from the Countries Master List in the "Cities" list.

Sunday, March 15, 2015

Adding new item with lookup column value

Adding the new city name in the "Cities" list where country name column has been used as "Look up" column.

Lookup column enables the user to retrieve the data from the other list within the site.

User need to add the city name in the text box and select the country name
from the drop down list box (lookup column).
To enact this scenario through programmatically,we can use SPFieldLookupValue class in SharePoint.

SPFieldLookupValue takes the Countries list's Item ID where UAE been added.

 using(SPSite site = SPContext.Current.Site)
            {
                using(SPWeb web = site.OpenWeb())
                {
                    try
                    {
                        web.AllowUnsafeUpdates = true;
                        var list = web.Lists["Cities"].AddItem();
                        var item = list.ListItems.Add();
                        SPFieldLookupValue lookupVal = new SPFieldLookupValue(3, "UAE");
                        item["Title"] = "Abu Dhabi";
                        item["Country"] = lookupVal;
                        item.Update();
                        web.AllowUnsafeUpdates = false;
                        updateStatus.Text = "Item updated successfully !";
                    }
                    catch(SPException ex)
                    {
                        updateStatus.Text = ex.Message;
                    }
                }