Tuesday, 18 February 2014

Synchronous Event LookUp Value on After Properties - SharePoint

HI All,
 Today We will see about getting the value of a LookUp field in a Synchronous Event.
There is a major difference in getting the value of the same when the following two things are called.
1)properties.ListItem
2)properties.AfterProperties

For the first , properties.ListItem
We have to make call like this,
          
    SPFieldLookupValue prevItemValue = new SPFieldLookupValue(properties.ListItem["FieldName"] as string ?? string.Empty);
    string FieldNameListItem = prevItemValue.LookupValue;

And for the second, properties.AfterProperties

   SPFieldLookupValue newItemValue = new SPFieldLookupValue(properties.AfterProperties["FieldName"] as string ?? string.Empty);
   int str1 = newItemValue.LookupId;
   SPList targetList = properties.Web.Lists["Target List"];
   SPListItem targetItem = targetList.GetItemById(str1);
   string FieldNameAfterProperties = targetItem["ParentField"].ToString();


On seeing the piece of code for properties.ListItem we can easily understand the logic how it works.

For the second one, a small detour has been done to get the value.
On calling properties.AfterProperties we only get the Id of the particaular item and the value is missed. So for getting the value of that field in After properties we have to query the master list,s master column.

Hope you all understand. Please drop your queries for any further clarification.
Thanks for your Time.. See you on my next post...

Sunday, 16 February 2014

Bring back the BreadCrumb in SharePoint 2013

HI All,
 Today we will see how to add the breadcrumb in SharePOint 2013. To know about BreadCrumb, Please check here.

It seems like this feature has been removed in SharePoint 2013. But the real fact is that this BreadCrumb trail has been hidden from the End Users.

OK lets see how to get back the same.

1.Open your site with SharePoint designer

2.Navigate to All Files -> _catalogs -> master page

3.Edit the Seattle.master in advanced mode and copy all the code

4.By default it’s not possible to edit the original master. To create a new one click on File -> Blank Mater Page

5.Check out the new master, edit it in advanced mode, delete all the existent code and paste the one from the original Seattle

6.Search for <div class="ms-breadcrumb-dropdownBox" style="display:none;">
 Remove the CSS attribute, style="display:none;

7.Two lines bellow change the visible attribute of the SharePoint:PopoutMenu to true.

So Finally the code should look like,
<div class="ms-breadcrumb-dropdownBox">
<SharePoint:AjaxDelta id="DeltaBreadcrumbDropdown" runat="server">
 <SharePoint:PopoutMenu
  Visible="true"
  runat="server"
  ID="GlobalBreadCrumbNavPopout"


Thanks for your time. See you back on my next post.