Monday, August 15, 2011

Load SharePoint List Items Using Server Object Model

using (SPSite site = new SPSite(ServerUrl))
{
    using (SPWeb web = site.OpenWeb())
    {
 
        SPList Tasks = web.Lists[TaskListName];
        // What ever u want
    }
}

How to use SharePoint Client Object Model to get User Information by User Lookup ID

protected string getUserEmail(int lookupid)
{
    String Useremail = string.Empty; 
 
    try
    {
        using (ClientContext clientContext = new ClientContext(siteUrl))
        {
            Microsoft.SharePoint.Client.ListItem userInfo = clientContext.Web.SiteUserInfoList.GetItemById(lookupid);
            clientContext.Load(userInfo);
            clientContext.ExecuteQuery();
            Useremail = userInfo["EMail"].ToString();
        } 
 
    }
    catch (Exception ex)
    {
        // TODO: // handle the error             
    } 
 
    return Useremail;
}

Load/Retrieve SharePoint List Items Using CAML in Client Object Model

 

you can use following code segment to load data from SharePoint list using client object model. Microsoft.SharePoint.Client DLL should get from the 14/BIN folder.

ClientContext clientContext = new ClientContext(siteUrl);
clientContext.Load(clientContext.Web);

Microsoft.SharePoint.Client.List oList = clientContext.Web.Lists.GetByTitle(tasklistName);
clientContext.Load(oList);

Microsoft.SharePoint.Client.CamlQuery cm = new CamlQuery();
cm.ViewXml = “<View>Some Query</View>”;
Microsoft.SharePoint.Client.ListItemCollection items = oList.GetItems(cm);

clientContext.Load(items);
clientContext.ExecuteQuery();

Saturday, August 13, 2011

One or more activex controls could not be displayed because either

This Error comes to me when i try to open Services.mcs

Following fix worked for me.

Fix Me (Download and Run this)

Friday, August 12, 2011

An entry has been added to the Windows event log of the server. Log ID:7893

This error cause to have an error occurred querying a data source in InfoPath when trying to query User profile service.

This error is very strange because it is happening only some times. most of the time in the first time. 

I found that following workout resolve the problem. in here i change the User profile service running application pool identity to someone who had access in the user profile service sharing.

Following are the steps..

image

Then go to advanced settings and change the identity.

image 

Make sure the account has accessed in user profile service sharing.

image

image

Wednesday, August 3, 2011

The error description is 'An invalid character was found in text content.'. sp_xml_removedocument: The value supplied

 

This error happened to me when i try to add xml to the SQL server. this is because of i didn't mentioned the proper character set in the XML.

Thus is used following character set definition in the top of the XML. 

<?xml version="1.0" encoding="windows-1252" ?>