Search This Blog

Total Pageviews

Monday, October 31, 2011

Joins in SharePoint COM


private void GetParts(string searchSku)
{
  Parts.Clear();
  List partsList = clientContext.Web.Lists.GetByTitle("Parts");
  List inventoryLocationsList = 
    clientContext.Web.Lists.GetByTitle("Inventory Locations");

  CamlQuery camlQueryPartsList = new CamlQuery();
  camlQueryPartsList.ViewXml =
    @"<View>
        <Query>
          <Where>
            <BeginsWith>
              <FieldRef Name='SKU' />
              <Value Type='Text'>" + searchSku + @"</Value>
            </BeginsWith>
          </Where>
        </Query>
      </View>";

  CamlQuery camlQueryInvLocationList = new CamlQuery();
  camlQueryInvLocationList.ViewXml = 
    @"<View>
        <Query>
          <Where>
            <BeginsWith>
              <FieldRef Name='PartLookupSKU' />
              <Value Type='Lookup'>" + searchSku + @"</Value>
            </BeginsWith>
          </Where>
          <OrderBy Override='TRUE'>
            <FieldRef Name='PartLookupSKU' />
          </OrderBy>
        </Query>
        <ViewFields>
          <FieldRef Name='PartLookup' LookupId='TRUE' />
          <FieldRef Name='PartLookupSKU' />
          <FieldRef Name='PartLookupTitle' />
          <FieldRef Name='PartLookupDescription' />
          <FieldRef Name='BinNumber' />
          <FieldRef Name='Quantity' />
        </ViewFields>
        <ProjectedFields>
          <Field Name='PartLookupSKU' Type='Lookup' List='PartLookup'                    
                 ShowField='SKU' />
          <Field Name='PartLookupTitle' Type='Lookup' List='PartLookup' 
                 ShowField='Title' />
          <Field Name='PartLookupDescription' Type='Lookup' List='PartLookup' 
                 ShowField='PartsDescription' />
        </ProjectedFields>
        <Joins>
          <Join Type='LEFT' ListAlias='PartLookup'>
          <!--List Name: Parts-->
            <Eq>
              <FieldRef Name='PartLookup' RefType='ID' />
              <FieldRef List='PartLookup' Name='ID' />
            </Eq>
          </Join>
        </Joins>
      </View>";

  partListItems = partsList.GetItems(camlQueryPartsList);
  inventoryLocationListItems = 
    inventoryLocationsList.GetItems(camlQueryInvLocationList);
  
  clientContext.Load(partListItems);
  clientContext.Load(inventoryLocationListItems);
  clientContext.ExecuteQueryAsync(onQuerySucceeded, onQueryFailed);
}


Saturday, October 29, 2011

Get ALL ListNames through Client object Model


ClientContext clientContext =
            new ClientContext("http://intranet.contoso.com");
        ListCollection listCollection = clientContext.Web.Lists;
        clientContext.Load(
            listCollection,
            lists => lists
                .Include(
                    list => list.Title,
                    list => list.Hidden)
                . Where(list => ! list.Hidden)
             );
        clientContext.ExecuteQuery();
        foreach (var list in listCollection)
            Console.WriteLine(list.Title);

Client Object Model Sample

Get All List Items :
ClientContext clientContext = new ClientContext("http://intranet.contoso.com");
 List list = clientContext.Web.Lists.GetByTitle("Announcements");
 CamlQuery camlQuery = new CamlQuery();
 camlQuery.ViewXml = "<View/>";
 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, oListItem["Title"]);
Creating List using COM, Add Fields and populate Data:
ClientContext clientContext =
            new ClientContext("http://intranet.contoso.com");
        Web site = clientContext.Web;

        // Create a list.
        ListCreationInformation listCreationInfo =
            new ListCreationInformation();
        listCreationInfo.Title = "Client API Test List";
        listCreationInfo.TemplateType = (int)ListTemplateType.GenericList;
        List list = site.Lists.Add(listCreationInfo);

        // Add fields to the list.
        Field field1 = list.Fields.AddFieldAsXml(
            @"<Field Type='Choice'
                     DisplayName='Category'
                     Format='Dropdown'>
                <Default>Specification</Default>
                <CHOICES>
                  <CHOICE>Specification</CHOICE>
                  <CHOICE>Development</CHOICE>
                  <CHOICE>Test</CHOICE>
                  <CHOICE>Documentation</CHOICE>
                </CHOICES>
              </Field>",
            true, AddFieldOptions.DefaultValue);
        Field field2 = list.Fields.AddFieldAsXml(
            @"<Field Type='Number'
                     DisplayName='Estimate'/>",
            true, AddFieldOptions.DefaultValue);

        // Add some data.
        ListItemCreationInformation itemCreateInfo =
            new ListItemCreationInformation();
        ListItem listItem = list.AddItem(itemCreateInfo);
        listItem["Title"] = "Write specs for user interface.";
        listItem["Category"] = "Specification";
        listItem["Estimate"] = "20";
        listItem.Update();

        listItem = list.AddItem(itemCreateInfo);
        listItem["Title"] = "Develop proof-of-concept.";
        listItem["Category"] = "Development";
        listItem["Estimate"] = "42";
        listItem.Update();
        
        listItem = list.AddItem(itemCreateInfo);
        listItem["Title"] = "Write test plan for user interface.";
        listItem["Category"] = "Test";
        listItem["Estimate"] = "16";
        listItem.Update();

        listItem = list.AddItem(itemCreateInfo);
        listItem["Title"] = "Validate SharePoint interaction.";
        listItem["Category"] = "Test";
        listItem["Estimate"] = "18";
        listItem.Update();

        listItem = list.AddItem(itemCreateInfo);
        listItem["Title"] = "Develop user interface.";
        listItem["Category"] = "Development";
        listItem["Estimate"] = "18";
        listItem.Update();

        clientContext.ExecuteQuery();
http://www.codeproject.com/KB/sharepoint/SP2010ClientObjectModel.aspx

Users AD Browser Webpart

Thursday, October 13, 2011

SharePoint 2010 News Rotator

Using the SharePoint 2010 Silverlight Client Object Model and Excel Services REST API

SharePoint Multiple files Download as zip file

SharePoint Multiple files Download as zip file


The user has selected some documents and a sub-folder so my custom ribbon button is enabled:

The user clicks on this button and this feature executes and after it’s complete the user is prompted with this (note, the filename is a timestamp):

The user saves it down locally to his computer and sees all the files are there:
WSP file (Site collection feature): DeviantPoint.DownloadZip.wsp (84.84 kb)
Visual Studio 2010 Project file: DeviantPoint.DownloadZip.zip (317.01 kb)




Exchange WebPart for SharePoint 2010

"Take a picture" Field for SharePoint 2010

SharePoint 2010 Chat Webpart using COM

Wednesday, October 12, 2011

SharePoint 2010 order ListField


http://sp2010order.codeplex.com/

SharePoint Mailing Feature

Sharepoint 2010 rotator

Rotator is a web part for SharePoint 2010 that rotates through any kind of list with animations. It uses jQuery and the cycle plugin for a rich user experience without the need for Flash or Silverlight. Add a little splash to your SharePoint site! 







SharePoint 2010 picture Library webpart

Edit SharePoint Field properties, including lookup column list association, with client side code only

List of Codeplex Downloads Part 2

List of Codeplex Downloads Part 1

1. Taxonomy breadcrumb inside the List Item



Available Free Extensions

SP List Advanced Search enables AND/OR search conditions on every SharePoint lists without SharePoint enterprise license. User can use this feature easily via Ribbon UI.
SP List Item Copy enables a user to copy SharePoint list items.
SP List Toolbar enables a user to navigate to the New Item page, the New Folder page, the Advanced Search page, and the List Settings page with one click, and also enables a user to change the view using a drop-down menu.
SP List Quick Filter displays the sidebar on the left side of the list view. The hyperlink on the sidebar can change the view of the list and filter the list items.
SP List Creation Menu displays items on the menu to create lists or libraries under the 'Site Actions' menu.






6. Cascade filtered lookup Column