Querying SharePoint List Items using jQuery

Due to popular demand I’ve created another sample of how you can make use of the jQuery Javascript library in your SharePoint sites. This example uses SharePoint’s Lists.asmx web service to retrieve all the list items of a specific list. In my previous posts I showed how you could use jQuery in SharePoint Site Pages (regular .aspx pages uploaded to a Document Library), so let’s do something different now; let’s use jQuery in a plain Content Editor Web Part.


To try this sample navigate to the home page (usually /default.aspx) of a SharePoint site that has a list with some list items in it, in my code I’ll use the Task list of a plain vanilla Team Site. Switch the page to Edit mode (Site Actions, Edit Page), and add a new instance of the Content Editor Web Part to the page. In the properties of that web part, copy and paste the following code using the Source Editor button.


<script type=”text/javascript” src=”http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js”></script>


<script type=”text/javascript”>
    $(document).ready(function() {
        var soapEnv =
            “<soapenv:Envelope xmlns:soapenv=’http://schemas.xmlsoap.org/soap/envelope/’> \
                <soapenv:Body> \
                     <GetListItems xmlns=’http://schemas.microsoft.com/sharepoint/soap/’> \
                        <listName>Tasks</listName> \
                        <viewFields> \
                            <ViewFields> \
                               <FieldRef Name=’Title’ /> \
                           </ViewFields> \
                        </viewFields> \
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>”;


        $.ajax({
            url: “_vti_bin/lists.asmx”,
            type: “POST”,
            dataType: “xml”,
            data: soapEnv,
            complete: processResult,
            contentType: “text/xml; charset=\”utf-8\””
        });
    });


    function processResult(xData, status) {
        $(xData.responseXML).find(“z\\:row”).each(function() {
            var liHtml = “<li>” + $(this).attr(“ows_Title”) + “</li>”;
            $(“#tasksUL”).append(liHtml);
        });
    }
</script>


<ul id=”tasksUL”/> 


On the first line the jQuery library is loaded from googlecode.com. To make this your, your client browser needs to have Internet access of course. Alternativly you can host the jQuery library yourself (see my previous examples) or even load the jQuery library in every page using the SmartTools.jQuery component. After that a function is attached to the jQuery document ready event. In this function the SOAP envelope message is constructed (the soapEnv variable). If you’d like to see the code getting list items from another list than the Task list, you’d have to change the listName element. The second part POST-ing the SOAP envelope to the web service by using jQuery’s ajax function. When the web service comes back with the result, the processResult method is called. In this function a loop is created over every row element (in the namespace z). Notice that “z:row escapes in Javascript to “z\\:row“. For every row element a new li HTML element is added to the ul element with ID tasksUL. And that’s it! You can see the result in the screenshot below.


Rundown on WCF, WF, and ’Dublin’ sessions @ TechEd next week

As I spend much of this week finalizing items for TechEd next week, I thought it might be helpful to post a schedule of the great content that will be presented at the event.

If you haven’t already pre-registered for sessions, now is an excellent time to look through the schedule builder and check out all the great content and speakers we have lined up at the event.

As is tradition, the bulk of the Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) sessions are in the SOA and Business Process track. This year, we are joined in the SOA track by sessions covering the ’Dublin’ technology extensions for Windows Server, which allow you to easily host and manage your .NET 4 WCF and WF applications.

Breakout Sessions

This year, we’ve assembled some of the greatest speakers on the topics, so please join us for the following breakout sessions:

Session

Title

Speaker

Timeslot

Room

SOA201

A First Look at WCF and WF in the Microsoft .NET Framework 4

Aaron Skonnard

Tues, May-12; 8:30am

Petree Hall D

SOA202

A Lap around Microsoft Code Name "Dublin"

Dan Eshner

Tues, May-12; 2:45pm

Room 404

SOA206

Every Class As a Service: WCF As the New Microsoft .NET

Juval Lowy

Thus, May-14; 2:45pm

Room 151

SOA302

Building RESTful Services Using WCF

Jon Flanders

Thurs, May-14; 10:15am

Room 404

SOA303

Busy Microsoft .NET Developer’s Guide to WCF, SOA, and Success

Jon Flanders

Fri, May-15; 1:00pm

Room 151

SOA309

Load Balancing and Scaling Your WCF Services Today and Tomorrow

Mich%u00e8le  Leroux Bustamante

Weds, May-13; 4:30pm

Room 515B

SOA310

Managing, Tracking, and Troubleshooting Services in "Dublin"

Ford McKinstry

Tues, May-12; 4:30pm

Room 403A

SOA401

Developing Service Oriented Workflows

Brian Noyes

Weds, May-13; 8:30am

Room 502B

For those unable to attend TechEd in person, my understanding is that all of the breakout sessions above will be recorded and be made available online. As we get more information post-event, we will post additional information up here on the blog.

In addition to the breakout sessions above, there is content that will be presented at TechEd that will unfortunately not be made available online after the event, this comes in three forms: the pre-conference sessions and interactive theatre sessions.

Pre-Conference Session

As I mentioned in my blog post on Friday, Zoiner Tejada and Michele Leroux Bustamante will be presenting a pre-conference on Sunday, the day before TechEd (PRC07: A Day of WCF + WF + "Dublin") that covers WCF and WF for .NET 4. The day is full of presentations and demos, and Michele and Zoiner have worked hard to update the session to cover the beta 1 features we’re talking about here. There are still seats available for the pre-conference, and it looks to be a real treat for those who can make it.

Interactive Theatre Sessions

Additionally, there are interactive theatre sessions that happen on the event floor among the booths. Within the Application Platform section of the floor (you can find us by looking for lots of blue), we have two theatres. Within the interactive theatres, we will have the following three sessions over the course of the week in Blue Theatre 2 that many folks are sure to find interesting:

Session

Title

Speaker

Timeslot

SOA02-INT

Communicating with State Machine Workflows

Philip Wolfe

Tues, May-12

1:00pm

SOA03-INT

Interacting with Web Services Using Microsoft Silverlight

Yavor Georgiev

Tues, May-12

4:30pm

SOA05-INT

Migrating a WF 3.0 Application to the Microsoft .NET Framework 4 and Microsoft Code Name "Dublin"

Tom Castiglia

Zoiner Tejada

Weds, May-13

10:15am

Hands On Labs

We also have six hands on labs at TechEd this year, the two introducing labs have been updated based on past event feedback, and we’ve added four of brand new labs! If you have an 45-60 minutes and like to get your hands dirty with some code while you learn, please check them out:

HOL Code

HOL Title

SOA09-HOL

WCF REST: Addressability of Resources

SOA10-HOL

WCF REST: Exposing a Resource Collection with the WCF REST Starter Kit

SOA12-HOL

WCF 3.5: Introducing Windows Communication Foundation 3.5

SOA13-HOL

WCF 3.5: Unit Testing Windows Communication Foundation 3.5

SOA14-HOL

WCF and WF 3.5: Using Advanced Context Management in WCF Workflow Services 3.5

SOA15-HOL

WF 3.5: Introduction to Windows Workflow Foundation 3.5

Booth

Then of course there is always the booth. The booth is open every day of the conference, and we’ll have folks there through lunch and during sessions – ready to chat with you about the technologies and show you how things work. If you have questions about WCF, WF, or ’Dublin’, or would like to learn more about how the technologies may apply to your solution – feel free to drop by.

Over the course of the week, we have folks at the booth that can talk at a high level (BTW-that’s me 😉 ), all the way to folks that can talk through how and why the API works the way it does. And if you can’t get your question answered at that time, we should be able to help you connect with someone at the booth who can help, or getting you the answer post-conference. We have a really good crew at the booth again this year (and I’m told we have a small white board at the booth this year!)

All of that being said, we hope to see you in LA next week and to learn more about how you’re using WCF and WF today – it should be a lot of fun all around. And for those unable to attend, check out the online recordings and continue to engage with us in the forums and the Connect site!

Hijacking the Database Lookup functiod

Here is the functiod description for the Database Lookup functiod:

Use the Database Lookup functoid to extract information from a database and store it as a Microsoft ActiveX Data Objects (ADO) recordset. This functoid requires the following four input parameters in this order: a lookup value, a database connection string, a table name, and a column name for the lookup value.

Let’s review the arguments again

1. Lookup Value
2. Database Connection String
3. Table Name
4. Column Name

I did not want to create a view, as I don’t have permissions to add objects to that database, but I could not simply get the value from one table, I needed to join two tables together.

The answer was SIMPLE!

Underneath the covers, the statement that is being called is:

using (OleDbCommand command = new OleDbCommand("SELECT * FROM " + table + " WHERE " + column + "= ?", helper.Connection))
{
...
}

WAIT A MINUTE! I am not limited to only a table name in the table variable of the OleDbCommand method, I can put an entire join statement in argument 3 of the Database Lookup functiod.

Here is what I had for the arguments:

The arguments without the single ticks

1. Source Data

2. Connection Information (in this case I just pointed to a udl file): ’File Name=D:\Eric\Warehouse\Schemas\connection.udl’

3. Table name, which has the join: ’EdiPartnerContacts INNER JOIN bts_party ON EdiPartnerContacts.PartyId = bts_party.nID’

4. Column that has the input value: ’nvcName’

So in essence I had created the following query using the DBLookup functiod

SELECT     * 
FROM         EdiPartnerContacts INNER JOIN 
                      bts_party ON EdiPartnerContacts.PartyId = bts_party.nID

WHERE       nvcName=?

I then pulled the Email column from the data in a Value Extractor that was connected to the Database Lookup functiod

Architect Insight Conference 2009

[Source: http://geekswithblogs.net/EltonStoneman]

Microsoft’s UK Architect Insight Conference will be held in their London office on Friday, 08 May 2009. The agenda has some great speakers on interesting topics, and in addition to the main presentations there will be interactive, round table discussion sessions throughout the day.

I’ll be hosting one of the interactive sessions entitled ESBs: what should you put in, and what will you get out? It’ll be a look at the sort of capabilities an Enterprise Service Bus could provision, and a discussion around how to select capabilities relevant to an implementation, based on anticipated strategic and business benefits.

There’ll be a couple of scene-setting slides and then hopefully an interesting discussion. I’ll follow up with a post on the outcome next week.

REMIX 2009 – Start City Sydney (11 June 09) – Next Generation Web

Remix 09 is on in June in Sydney. The details and registration site can be found at: http://www.microsoft.com/australia/remix/ 

REMIX09

THE NEXT WEB NOW

What’s it all about?

Ever since REMIX commenced it’s been a hit, with delegates returning each year to a sell out crowd. You know the Web is the future of commerce, education, and communication. REMIX is our way of helping you take it to the next level.

Now in it’s 3rd year, REMIX is the place to advance your web development and design skills, get in-depth exposure to exciting new Microsoft technologies, exchange ideas with fellow developers and designers, and meet the industry’s thought leaders.

At REMIX09 you can:

  • Explore the next wave of ideas and opportunities in Web development and design.
  • Get inspired by an impressive line-up of UX, design and development sessions.
  • Connect with experts on a wide range of topics for one-on-one guidance and inspiration.
  • Learn about the future of Silverlight%u2122, Internet Explorer%u00ae, Expression, ASP.NET and other web technologies from Microsoft.
  • Network with execs from Microsoft and hot interactive agencies.

REMIX09 is where you’ll find the best ideas, sessions, and people. To put yourself into the mix, book your tickets before they sell out.

Who should attend?

REMIX09 draws together coders, strategists, information architects, visual designers, UX professionals and digital marketers WHO ALL SHARE AN INTEREST ON WHAT’S COMING NEXT ON THE WEB.

BizTalk-Windows SharePoint services adapter issues

BizTalk Server 2006 Unable to determine whether or not specified user is an administrator.

You are attempting to install Windows SharePoint services adapter web service on a virtual server that has not been configured with Windows SharePoint Services

TITLE: Microsoft BizTalk Server 2006 Configuration Wizard

——————————

You are attempting to install Windows SharePoint Services Adapter Web Service on a virtual server that has not been configured with Windows SharePoint Services. Refer to the documentation for instructions on extending a virtual server. (CWssAdaCfg)

——————————

Solution: Make sure you run the Windows SharePoint Services Central Administration and Extend or upgrade virtual server, once its installed re-run the BizTalk configuration wizard, this time it should run smooth.

Screencast: Windows Workflow – Creating custom context channels for workflow services

Screencast: Windows Workflow – Creating custom context channels for workflow services

I’ve recently published a free screencast on how to create a custom context channel in workflow services. 

wf-custom-context-channel

.NET 3.5 supports managing context in a SOAP header or HTTP cookie, but that may not be where your context information lives. In this screencast I show an example of a custom channel that enables the context information to be passed in a URL to enable operation invocation from a link in an email.

 

Check out our growing collection of free .NET screencasts and videos.  Subscribe to the Pluralsight feed to be notified when new screencasts are published.  Also, check out our growing library of online .NET training courses — see what you can learn with Pluralsight On-Demand!

Screencast: Windows Workflow – Managing conversations in workflow services

Screencast: Windows Workflow – Managing conversations in workflow services

I’ve recently published a free screencast on how to manage conversations in workflow services. 

wf-managing-conversations

Conversations are special cases of context management in workflow services requiring extra information to correctly route messages. In this screencast, I show you when you need to think about conversations and how to properly write your workflows and clients to deal with them.

 

Check out our growing collection of free .NET screencasts and videos.  Subscribe to the Pluralsight feed to be notified when new screencasts are published.  Also, check out our growing library of online .NET training courses — see what you can learn with Pluralsight On-Demand!