Share via


Commerce Foundation SharePoint List Integration

A SharePoint list is a custom or out-of-the-box list provided by SharePoint that allows you to customize, by adding and removing columns, and creating views. The list is managed within the SharePoint management interface. In a SharePoint site, you can create SharePoint sites and use the ContentQuery Web Part to retrieve data from a list and display it on the screen. In a non-SharePoint site, this data would typically be unavailable. SharePoint list support makes this data available and enables relationships with other commerce entity data in a transparent way to any channels in the solution. Mapping a SharePoint list to a Commerce Entity allows the use of SharePoint lists for additional site content such as ratings and provides a mechanism for retrieving that data from sites running without SharePoint or channels where SharePoint is not available.

Functionally, SharePoint lists behave as commerce entities derived from other sources. The primary difference that will be noticed is that SharePoint uses CAML queries to query a list instead of SQL-based queries. The following shows a query operation:

string ListItemId = "1";
CommerceQuery<CommerceEntity> queryRequest = new CommerceQuery<CommerceEntity>("spAnnouncements");

            //Specify fields to return
            queryRequest.Model.Properties.Add("Title");
            queryRequest.Model.Properties.Add("Body");

//Specify the search criteria 
            queryRequest.SearchCriteria.WhereClause = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" 
+ ListItemId + "</Value></Eq></Where>";

Note

The SearchCriteria.WhereClause is a CAML (XML based expression) query.

Model

You can modify this commerce entity, as required. This model, taken from the out-of-the-box site, is provided as an example. Note that this is a representative example of a single SharePoint list mapping (Announcements). This entry would have to be repeated for each list that is mapped. The individual configuration elements (Server, Site, Port, ListName, ViewName) are configured for each list. This provides the capability of mapping to lists from different sites within the same server or completely different SharePoint servers. These properties are present to provide Metadata about the list itself and will not be returned as individual properties within the list.

<CommerceEntity name="spAnnouncement">
     <DisplayName value="Announcements" />
     <Description value="Maps to SharePoint Announcements list" />
     <Properties>
         <Property name="Server" dataType="String" >
             <DisplayName value="Server" />
             <Description value="Server" />
             <DefaultValue value="localhost" />
         </Property>
         <Property name="Site" dataType="String">
             <DisplayName value="Site" />
             <Description value="Site" />
             <DefaultValue value="" />
         </Property>
         <Property name="Port" dataType="Integer">
             <DisplayName value="Port" />
             <Description value="Port" />
             <DefaultValue value="13653" />
         </Property>
         <Property name="ListName" dataType="String">
             <DisplayName value="ListName" />
             <Description value="ListName" />
             <DefaultValue value="Announcements" />
         </Property>
         <Property name="ViewName" dataType="String">
             <DisplayName value="ViewName" />
             <Description value="ViewName" />
             <DefaultValue value="" />
         </Property>
     </Properties>
</CommerceEntity>

Operation Sequence Components

Component

Description

SharepointListItemProcessor

This processes SharePoint list items.

Enabling SharePoint List Integration

Unless you have a valid endpoint address specified, Microsoft Multi-Channel Commerce Foundation will throw an exception. To enable this feature you must perform the following tasks.

Add and endpoint in Web.config

In the Web.config file, add the endpoint configuration entry corresponding to a SharePoint List service, for example:

<endpoint address="https://localhost:13653/_vti_bin/lists.asmx"

binding="basicHttpBinding" bindingConfiguration="ListsSoap"

contract="SharepointListService.ListsSoap" name="ListsSoap" />

Add references in MetadataDefinitions.xml

In your MetadataDefinitions.xml file, add references to any required commerce entities used by SharePoint Lists such as spAnnouncements, for example:

<CommerceEntity name="spAnnouncements">
        <DisplayName value="Announcements" />
        <Description value="Maps to Sharepoint Announcements list" />
        <EntityMetadata>
          <Property name="IsSharepointList" dataType="String" >
            <DefaultValue value="True" />
          </Property>
          <Property name="Server" dataType="String" >
            <DefaultValue value="localhost" />
          </Property>
          <Property name="Site" dataType="String">
            <DefaultValue value="" />
          </Property>
          <Property name="Port" dataType="Integer">
            <DefaultValue value="13653" />
          </Property>
          <Property name="ListName" dataType="String">
            <DefaultValue value="Announcements" />
          </Property>
          <Property name="ViewName" dataType="String">
            <DefaultValue value="" />
          </Property>
        </EntityMetadata>
      </CommerceEntity>

See Also

Other Resources

SharepointListItemProcessor