Sunday, 30 November 2014

User Information List in SharePoint

The User Information List stores information about a user by having some metadata set up for the user.
When a user is granted access to a site, a new item will be created in the User Information List storing some information about the user.

When a user add/create or edit an item, SharePoint will display something like "Last modified at 1/1/2014 by myname myname" . Displayname is gathered from the User Information List.

The User Information List can be accessed (Only if you’re admin) via the browser by navigating to /_catalogs/users/simple.aspx from your site.

User information list is filled with user info when:

1. you grant permissions directly to this user (not via group)
2. user visits site collection first time (users are stored on site collection level, not on site. The fact that /_catalog/users may show different users on different site on the same site collection just says that there is some additional filtering logic)
3. you call SPWeb.EnsureUser() programmatically.

Note: This list is only visible to and accessible by administrators.

Thursday, 23 October 2014

Content Query WebPart returning no data - Sharepoint 2013

Hi All,

Its been a long time since i had posted. Last week i got a weird issue, that made me do this post.

Content query webpart helps in retreiving the data throughout your Site Collection. In Sharepoint 2013 when I used this CQWP to get data, I had a condition where no data were retrieved. In this condition, the HTML of that particular page got distorted and the webpart zones got shifted.
So everything went on to a mess. It took some time for me to get the fix for this issue.

Please find the solution to fix this issue.

Open the ContentQueryMain.xsl in SharePoint Designer. Find the XSL template OuterTemplate.Empty. As you can see it poorly handles the "no items" situation.

Replace the template with this:

<xsl:template name="OuterTemplate.Empty">
  <xsl:param name="EditMode" />
  <xsl:choose>
    <xsl:when test="$EditMode = 'True' and string-length($cbq_errortext) = 0">
      <div class="wp-content description">
        <xsl:value-of disable-output-escaping="yes" select="$cbq_viewemptytext" />
      </div>
    </xsl:when>
    <xsl:otherwise>
      <div style="display:none">No content found</div>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Have a good day :)

Friday, 4 July 2014

Jquery selectors - Wildcards for Finding Sharepoint fields with Internal Names in newform,editform and Displayform.

Hi All,
 Today we will see something related to jQuery. This was helpful when i tried to get the internal names of the columns in the newform, editforms.

Getting the controls in the forms using the label names would be inconsistent, as the labels could be changed frequently causing our code to break. So we have to query the fields using "id" of that element.

For example, if there is a control named "Project Name", its id could be "ProjectName_12h1278hk9kkhasfkcyh9"..

That is, "Internal Name of the column("ProjectName) + some junk"

These wild card selectors were very useful in finding the controls. This would be of a great help when u come across these sort of situations.


If you want to select elements with an id which ends with a given string :
$("[id$='myValue']")


If you want to select elements with an id which starts with a given string :
$("[id^='txtTitle']")


If you want to select elements which id contains a given string  :
$("[id*='txtTitle']")


If you want to select elements which id is not a given string  :
$("[id!='myValue']")
(it also matches the elements that don't have the specified attribute)


If you want to select elements which id contains a given word, delimited by spaces :
$("[id~='myValue']")


If you want to select elements which id is equal to a given string or starting with that string followed by a hyphen:
$("[id|='myValue']")


Have a good day....

Tuesday, 3 June 2014

Sorting the Lookup field values based on any columns on Lookup list using SPServices SPFilterDropdown

Hi Everyone,
 Today we will be seeing a common requirement which will used very frequently, and there is OOTB way to do this.

The requirement is "sorting the Lookup field values". Usually it gets sorted automatically "alphabetically".

Sometimes, we need to have them as in same order as they have stored in the list. For this we are going to sort the values of the lookup based on the ID on the lookup list.
Note : The lookup values can be sorted based on any columns. That depends on the requirement. For understanding i have used ID for that.

For this we are using SPServices, For using SPServices and to have a basic knowledge about SPservices, please refer here.

 $().SPServices.SPFilterDropdown({ //This is the function that does the sorting.
        relationshipList: "LookUp list", //This is the lookup list.
        relationshipListColumn: "Title", //This is the original column name from the lookup list as SharePoint knows it.
        relationshipListSortColumn: "ID", //This is the column in the lookup list to sort by.
        columnName: "LookUpcommitees", //This is the lookup field name .
        debug: true// have to be true on development times
    });


Have a good day:)

Saturday, 19 April 2014

Site Pages and Site Assets missing in your Newly Created SharePoint Site?

Sometimes when you create a site in SharePoint 2010, the Site Pages and Site Assets libraries are not created, yet other times, they are?

The answer lies in a feature called Wiki Page Home Page, which is enabled by default for Team Sites in SharePoint. However, other types of site templates may not activate that feature by default, and if that’s the case, those libraries won’t be there.

If you need them, you have a few options:
  • Activate the “Wiki Page Home Page” feature. The feature will create those libraries and will also create a wiki page and set it as the home (welcome) page for your site.
  • If you only need the libraries and don’t want your home page changed, you can have SharePoint Designer 2010 create the libraries for you:
    • Open SharePoint Designer.
    •  In the “Site Objects” pane on the left, click “Site Pages.” SP Designer will load the contents of the Site Pages library and tell you it’s empty. However, it also creates the Site Pages library for you in the process.
    • Do the same thing for “Site Assets” (also in the Site Objects pane). 
  • If you have code that depends on the existence of these libraries (such as a feature receiver), you can use two methods on the SPListCollection class to ensure the libraries are there:
    • EnsureSitePagesLibrary()
    • EnsureSiteAssetsLibrary()

Happy SharePointing!!!:)

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.



Friday, 10 January 2014

Programmatically Hiding the "Overwrite existing files" checkbox for a single library,, Solution-2

Hi Sharepointers,

In one of my previous posts, I shared one of the two solutions for hiding checkbox in Upload.aspx page for a single document library.
This time I will share the second solution for the same issue.


Solution 2) Edit the Upload.aspx (application) page.

When u try to edit this page, it reflects on all the document libraries.
So we need to check to perform the action on a single library, and this check will be the List GUID from the URL.


<%

    if (Request.QueryString["List"] == "{651489A5-0C0D-4774-B6FF-B995BB06D82A}")

       {

                                OverwriteSingle.Visible=false;
                                UploadMultipleLink.Visible=false;
      }

%>


Substitute the above with your List ID.
For easily finding the GUID of a library u can refer my post here
That's it. Work is done :)

See u next time :)......