Saturday, May 30, 2009

When working on big SharePoint projects we will get really good requirements and most of them are the challenging. In some cases we need to show the data by pulling from one list in a site to another site. For example, on “Site A” home page we want to show the data from another site or sub site. Then we need to use the web services and call the list and get the items. This is what this blog post is completely about.

How is it useful?

It is useful because as far as i know we have two ways of doing this without coding.

1. By using IFrames on the web pages. Create a content editor web part on the page of the site where you want to show the list content and add a IFrame and point it to the page where list data is present in another web site. So it is just doing nothing, just loading that page as it is. But it’s not a right way of implementing it. Because if authentication is different then you need to login to the site 2 times. One for the main site and another for the IFrame. Another problem is we can’t use IFrames on the web pages for security and performance issues. So it’s not a good way of doing. Then is there any other way?

2. Yes, We have a solution for this and it’s the better way of implementing it. Call a web services by connecting to the web services of the site we want to get the data, pass credentials and then select the list or library you want. Add a web part to the page and give the list we pulled from web service to the web part. That’s it. It is the easy and efficient way. I am explaining this a little bit detail below.

Create a SharePoint web part page for showing content by using web services.

Open the page in SharePoint designer and detach it from page layout.

Now, we need to add a web part for showing the data. We have a very comfortable and most usable web part in SharePoint nothing but Data View web part. Add this to the page.

Now, web part is ready and need of data source. So we need to go for list where we have to pull the data. It can be in the current site, sub site or some other site.

Go to Task pane menu item of SharePoint designer and select the Data Source Library. Now you are able to see the all the data sources exist in the current site only. For example, if you want to pull data from a list which is in subsite or some other site you can’t find the data source entry in the lists and libraries section. This is the time where we need to go for XML web services. See above figure for more details.

Now we need to add a new XML web service data source to our site. How difficult it will be? very simple, follow below.

Expand the node XML web services and you can find the link called “Connect to a web service”.

Now you are open up with a window where you can see the properties of the web service data source.Now we need to set the properties for the data source. Move to the tag General. Fill the name, description and keywords.

Move to tab source and fill the source description location. You can browse to the location of the site and add the which asmx file you want to add. Or if you know location you can manually enter the url. Usually the location is like this. http://sharepointserver/_vti_bin/lists.asmx?WSDL

Remember for example purpose, i given the lists.asmx file path, you can use any of available web service.

Before click on Connect now button, check the credentials. You have options for entering credentials, or use default/windows credentials or don’t ask for credentials etc. Set the credentials type and then say Connect now.

Now the command to configure. Our case, we want to show the data. So it should be the Select operation.

Select the port : ListsSoap [default one]

Select operation type : GetListItems

Now time to pass parameters to the data source. First thing is you need to select the listname parameter that from which list you need to get the data.You can pass parameters to the web service to filter the results too. For example, if your list has the boolean column for IsUpdated. Then we want to show only the columns which are having IsUpdated=false, then you can set that here. We are done with configuring and setting the data source properties.

We have data source ready and we need to use it to link to the data view web part.

If you set everything correct, then you can see the entry under the XML web service section.

Click on the data source and choose Show data from the menu.

Now, it will open Data Source Details task pane that pull all the column information from the list that you connected to as shown below.

Select the list of columns that you want to show on the page. [You can select multiple columns by pressing the control key.]

Now click on the option “Insert selected fields as” Multiple Item view. It will add all the selected columns to the Dataview web part.

Save the page and view it in browser.

How nice it is, and how simple it is?

Really thanks to SharePoint designer and Data view web part that makes our work easier.

Is it possible to call the web service and use a data item in a column of another list like you would using Business Data Column consume data from a web service that is in the BDC? I am trying to figure out how to get data from one list into another.

I think, this is not possible with the built-in SharePoint designer web services. You can still write simple code using the SharePoint object model or using the SharePoint web services. Is code allowed in your case?

Outstanding blog, nice presentation about web design and development in Miami I love the contents and thoughts. I am so happy to vote and just now I voted for your blog in blogger awards. Keep it up and write more please. I invite your precious visit and suggestions about my Blog and site also. Please make your choice for me also by using this link. Miami web design

This is a best weblog. I average it. You have got a best trade thought of this matter, and so much interest you have got a layout here that is not too flashy, but creates a statement as enormous as what youre expressing. Better job!.