Friday, November 18, 2011

SharePoint: How to show a client that you are the expert - End User - NothingButSharePoint.com

SharePoint: How to show a client that you are the expert - End User - NothingButSharePoint.com

SharePoint 2010: Use # to remove Web Part Title URL

When you add a list or library web part through the SharePoint UI, the web part title is automatically hyperlinked to the SharePoint list or library. For example, in the screenshot below, I have a standard Team Site homepage with a Shared Documents web part. The title of the web part is linked to the Shared Documents Library.



If you edit the web part, under the “Advanced” group, you will see Title URL where you can change the hyperlink of the web part title heading to another URL location.



However, if you decide to remove this Title URL value and click OK. SharePoint won’t allow the update. It would instead automatically re-enter the original URL value. To quickly get around that, Edit the Web Part and replace the URL with #


Once you click OK, you should be all set.


Cheers!!!

How does the SharePoint 2010 Client-Side Object Model work?


In my previous post we discussed about introduction to rest and the basics.


We have the client on the left and the server on the right. The server contains the SharePoint Databases and the Server-side Object model.



Between the server and client is a new WCF service called Client.svc. When you reference the client-side object model in your code,, the internal proxy class takes care of sending requests and review responses via the WCF Service.

The very important thing to notice here is that we don’t want to send requests to the server and get a response for almost every line of code we execute. So how it is designed to work is that in your code you will construct the objects and execute standard SharePoint OM functions. The objects will be empty structures without properties and without data, and the functions will not execute right away.



Then at logical points you bundle everything together and send it to the server for processing. The server will then unpack your bundled code and execute it in the correct order and return JSON to your client-side. Your objects will then be populated with data and properties and you can carry on executing more code. The important concept to understand is that you bundle empty objects together and send to the server when ready for processing.



The SharePoint Foundation 2010 managed client model consists of Two Assemblies that contains five namespaces.



There are 3 types of client object models.

1. Managed Client Object model


2-Silverlight Client Object model


3-ECMAScript Client Object model



1-Managed Client Object model:

This is used to extend Windows Form applications, services, WPF applications, console applications etc.

It consist of Microsoft.SharePoint.Client.dll (282 kb) and

Microsoft.SharePoint.Client.Runtime.dll (146 kb)



2-Silverlight Client Object model:

This is used to Silverlight Applications.

It consist of Microsoft.SharePoint.Client.dll (282 kb) and

Microsoft.SharePoint.Client.Runtime.dll (146 kb)



3-ECMAScript Client Object model:

JavaScript in our SharePoint user interface.

It consist of:

CUI.js (344 kb)

SP.js (381 kb)

SP.Core.js (13 kb)

SP.Ribbon.js (208 kb)

etc...



You will notice that there are a few differences between the objects in the Client-Side Object model and the Server-side Object model:


Lets build some simple code:

Create a new Visual Studio 2010 Console application

Add a references to:


Microsoft.SharePoint.Client.dll and
Microsoft.SharePoint.Client.Runtime.dll


Ensure your console app code look as follows:

using System;
using Microsoft.SharePoint.Client;

class demoSharePointClient {
static void Main() {
ClientContext clientContext = new ClientContext("http://yourappname /");
Web site = clientContext.Web;
clientContext.Load(site);
clientContext.ExecuteQuery();
Console.WriteLine("Title: {0}", site.Title); } }

Press control+F5 and see your code execute.

Lets analyze the code:

You inform the managed client OM about the operations that you want to take.

This includes accessing the values of properties of objects (for example, objects of the List class, ListItem class, and Web class), CAML queries that you want to run, and objects such as ListItem objects that you want to insert, update or delete.

Then you call the ExecuteQuery method. Only when you call the ExecuteQuery will the objects be bundled up and sent to the server for processing. No network traffic occurs before then.



Another Example:

Create a new Visual Studio 2010 Console application

Add a references to:

Microsoft.SharePoint.Client.dll and
Microsoft.SharePoint.Client.Runtime.dll

ensure your console app code look as follows:



using System;
using Microsoft.SharePoint.Client;


class Program {
static void Main() {


ClientContext clientContext = new ClientContext("http://yourappname /");
List list = clientContext.Web.Lists.GetByTitle("Announcements");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "";
ListItemCollection listItems = list.GetItems(camlQuery); clientContext.Load(list);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
foreach (ListItem listItem in listItems)
Console.WriteLine("Id: {0} Title: {1}", listItem.Id, listItem["Title"]); }}


Press control+F5 and see your code execute.

Again, the code will be bundled up and only be sent to the server for processing when the .ExecuteQuery() run.

This means that although you called the list.GetItems the CAML did not execute at that time.

When you call the .ExecuteQuery(), the server will receive your code, unpack it and execute it in the correct sequence and return the objects populated with data and properties.... all processed on the server side... and ready to be further used on the client-side !!!!

Cheers!!!

Suneet



















Thursday, November 17, 2011

The query cannot be completed because the number of lookup columns it contains exceeds the lookup column threshold!!!

While doing migration i got this issue with a big list...using lots of lookup columns type..


This is due to SharePoint’s new resource throttling settings for managing large lists. There is an easy fix in Central Administration.


Go to Central Administration and then browse to Application Management > Manage Web Application.  Select the web application you need. 
In General Settings choose Resource Throttling. Set the value in the List View Lookup Threshold textbox to a higher value (equal to or greater than the number of site columns you are using on the list where you saw the error).

Cheers!!!
Suneet