Category Archives: Tahir Naveed

SharePoint 2013 - User Profile Properties through JSOM


You may also be interested in: fpweb.net


 

Editor’s note: Contributor Tahir Naveed is a Microsoft SharePoint Specialist in the New York City region

Within an organization, users are created in an Active Directory and then imported to SharePoint through the User Profile Service. This service creates User Profiles in SharePoint which have properties like name, email, phone number, manager etc as well as some custom properties.

The following script will access four User Profile properties (Title, Department, Office location and Phone) through the JavaScript Object Model:



Example:

1. Create a blank ASPX page.

2. Add a Content Editor Web Part to the page.

3. Copy the above JavaScript on the page to get the following output

2013-10-16-UserProfileJSOM-01.png

Ref1: http://technet.microsoft.com/en-us/library/ee721054.aspx
Ref2: http://technet.microsoft.com/en-us/library/hh147510.aspx

SharePoint 2013 - Facebook Style Discussion with Like Button


You may also be interested in: SharePlus Office Mobile Client - The Universal Mobile SharePoint App


 

Editor’s note: Contributor Tahir Naveed is a Microsoft SharePoint Specialist at Orion Systems.

The famous "Facebook like" is one of the features that everybody wants these days so they can like/unlike everything they read and see over the internet. I was exploring the SharePoint 2013 Technical Preview‘s new features and how to use them in real world scenarios.  I came across the amazing new Discussion Board list and its configuration settings so that users can like/unlike a discussion, comment and a reply.

First I am going to show the new features (displayed in the image below) and then I will show you how to configure the like/unlike button (in the video below).

The new Discussion Board list has the following cool features:

  1. Display Picture - Now users can see the person who has started the discussion and who is replying.
  2. Rich text - Users can reply with rich text to highlight the important parts of the conversation in their comments.
  3. Reply to Reply - Users can now reply to an existing reply just like the discussion topic.
  4. Multimedia Reply - Users can attach a picture, video or a simple link within their reply to provide a reference etc.
  5. like a reply - Users can rate a post by liking it.
  6. Best Reply - A reply can be marked as Best reply in order to avoid other users having to dig for an answer in the thread.

The following video shows how to configure the Discussion Board list for Facebook style like Button on posts:

SharePoint 2010: Join Two Lists Child/Parent Relationship


You may also be interested in: SharePoint Apps by Cybozu


 

Editor’s note: Contributor Tahir Naveed is a Microsoft SharePoint Specialist at Orion Systems.

This post explains how to implement the child parent relationship between two lists/tables. Two lists will have one common field ID from a Category list. The Category.ID will act as a primary key in a Category list and will be used in a Products list as a foreign key to match the items. The diagram below illustrates the relationship that has been implemented in the video.

2012-07-25-ParentChild-01.jpg

Child Parent Relationship

2012-07-25-ParentChild-02.png

This tecnique can also be used in SharePoint 2007 via SharePoint Designer 2007. However, the Data Source and Data View web part’s menu options are a little different.

SharePoint 2010 - Implement Search in a List (No Code)


You may also be interested in: SharePlus Office Mobile Client - The Universal Mobile SharePoint App


 

Editor’s note: Contributor Tahir Naveed is a Microsoft SharePoint Specialist at Orion Systems.

This tutorial explains how to implement search functionality in a list without any code.

I recently had a requirement to implement a search page for a List where users pass a search phrase via Query String (e.g. http://SharePoint2010:1000/Pages/Search.aspx?q=hello) and the search page will display the results from a List, based on that search phrase. I am excited to share the technique where one dosen’t have to write a code to develop such a page and everything can be taken care of easily via SharePoint Designer.

 

 

 

This technique can also be used in SharePoint 2007 via SharePoint Designer 2007. However the Data View Web Part’s options are available on the Data View context menu instead of the tool bar.

SharePoint Client Object Model using ECMAScript

 

Background

One of the coolest features of SharePoint 2010 is Client Object Model. You might already know that if we have to talk to SharePoint 2007 and don’t want to write the server side code then we call SharePoint Web Services. Now with SharePoint 2010 we can use Client Object Model to talk to SharePoint and the option of web services is still there. Once a wise man said, two options are always better than one.

How SharePoint Client Object Model Works

SharePoint Client Managed Object Model is a SharePoint API that runs on the client side. It converts the API calls made by the application, into XML request and sends it to the SharePoint server. On the server, the XML request is handled by a service called Client.svc where it translates the XML request in to appropriate Object Model calls (SharePoint Server Object Model) and gets the results. After getting the results, Client.svc translates them into JavaScript Object Notation (JSON) and sends back to the Client Managed Object Model. On the client side the JSON response is translated into ECMAScript objects for ECMAScript.

Ref1: http://msdn.microsoft.com/en-us/library/ee538253.aspx
Ref2: http://msdn.microsoft.com/en-us/library/ee857094(office.14).aspx

Writing the ECMAScript

  1. Create a list called Product and add few items in it.
  2. Create a test ASPX page in the Pages library.
  3. Add the Content Editor web part and add the following script in it.
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(MainFunction, "sp.js"); 
var objContext = null; 
var objWeb = null     
var objList = null;
var objItem = null;
    function MainFunction() {   
        objContext = new SP.ClientContext.get_current();
        objWeb = objContext.get_web();   
        objList = objWeb.get_lists().getByTitle("Product");
        objContext.load(objList);
        objContext.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFail));   
    }   
    function onSuccess(sender, args) {
        alert('Item Count: ' + objList.get_itemCount());
    }   
    function onFail(sender, args) {   
        alert('Some error has occured.');   
    }  
 </script>

Explanation

To load the Java script Client Object Model, we have to call ExecuteOrDelayUntilScriptLoaded(Func, "sp.js") . This function takes the name of the function that need to be executed as a main function and will load the SP.js file, which is the core of Client Object Model. We have to load the current context in order to play with the site content by SP.ClientContext and then get the current site by calling get_web() function of current context. After getting the current site we call getByTitle to get the Product list and then we loaded that list. Note that we are not loading all the objects but only the list. Loading all the objects will cause delay and performance issues. We are loading the list asynchronously and if the call is successful OnSuccess()will be called and if the call failes OnFail() will be called.

Conclusion

ECMAScript is a java script based client side scripting language which is now supported in SharePoint 2010 and can be used to access Client Object Model. Users can write ECMAScript in an ASPX page for SharePoint 2010 sites and can manipulate the SharePoint content without even touching the Visual Studio (or SharePoint Designer) and getting involved in the complexities of the web services.