Let’s say we have a traditional SharePoint 2010 Tasks list. The Assigned To field allows both users and groups. Tasks are being assigned both on individual level and on group level. How do you filter your tasks? SharePoint has several views for the Tasks list and two of them are relevant: My Tasks and By My Groups. The first is obvious and the second refers to the group membership of the current user. So, the answer is in the combination of the two.
An easy trick would be to create a web part page and add two web parts to it – one based on the My Tasks view (edit web part, select view) and the other based on the By My Groups view. You stack them on top of each other and that should work.
What we will do in this short article is actually combine them in one view. I created a view (in the browser) based on the By My Groups – actually exact copy. Then I headed to SharePoint Designer and opened the view for editing. I also opened the My Tasks view and switched both to code view. The focus is on the QUERY part. All you need to do is use an Or operator and copy the criteria from the My Tasks view.
The image shows the final query in context (code view of a copy of By My Groups view).
You can see, in the inset, that I have my tasks grouped (expandable and collapsible) whether they were assigned explicitly or implicitly (as part of a group I am a member of).
Yesterday I won my MCC Award (Microsoft Community Contributor) and decided to add this entry as a special gift to the community. This is a simple workaround and I saw a request a couple days back asking to hide the Add Document link after the list of items. In fact, the Add Document may encourage users to upload files from their computers rather than use the create new (select content type). Plus, you still have the upload document or multiple documents from the ribbon.
There are a few ways to do that, one of which is using the browser only – add a CEWP and hide the link using CSS (see this thread for more). A similar approach is to use JQuery and hide the cell that has the Add Document link (again, you add a CEWP, reference the JQ library and add the script (something like $(document).ready(function() { $(‘#WebPartWPQ2 .ms-addnew’).hide();});). If you are doing this on the All Items view page, you will notice that the document library web part loses focus and you have to click inside to show the Library Tools ribbon and switching between views is not as easy as it should be. This is because we have two web parts in the page (even if you hide the CEWP, which you should any way – just check the Hidden property under Layout). It turns out there is another easy and better way – customize the xslt in SharePoint Designer. Select the library (site objects – lists and libraries) and click the view you want to edit (top right). If you want to modify the number of items per page, do it first: List View Tools – Options – Paging (this is not required but if you do it later you will overwrite your custom view).
Now highlight the text “Add Document” and from Design tab (under list view tools), Actions group, select customize item (click the arrow next to customize xslt). Then, switch to code view. The source view should increase by around 80 lines (starts with <xsl>). Locate the line taht starts with <td class=”ms-addnew” and change its style to display:none
Save your page in SPD and check it back in the browser. The Add Document is no longer visible and the view functions as usual.
Note1: If all you have is a web part, you can also set Toolbar Type to “No Toolbar” in the web part properties and that will remove the Add Document.
Note2: yesterday was also the release date for SharePoint Service Pack 1 (check this post from Spence Harbar before you install it)
SharePoint Designer 2010 allows you to save a list view (which is simply a web part) as a webpart either in the top site gallery or as a file. You can then insert the web part into a parent or sub site to view the original (and any updates to) list items at the other site. This works between parent and sub site or the other way round. However, there seems to be an issue with saving the web part to the gallery directly. Instead, use the Save To File option.
Open the site where the original list is located in SharePoint Designer 2010, navigate to the list and select a view to export. Open the view and select the xsltview web part. From List View Tools, select the web part tab. Then, select To File (from save web part group). Type a name for the file (leave the extension as is) and answer Yes to the dialog that follows (do you want to show list data …).
Now, from your site collection’s site settings, select Galleries – Web parts. Click Documents from the ribbon’s Library Tools and upload the file you have just saved. Select a title and a group for your web part (so you’ll find it easily later). Now, in the other site, on a web part page (or any web part zone on a page), add a web part and select your group then your web part.
Saving to gallery directly seems to miss the Web ID (GUID) in the web part xml source (the element <property name=”WebId” ..></>) which references where the original list lives. You can edit the web part and fix it, of course, but easier to just save to file.
Note: if adding the web part from the browser results in an “unexpected error” and you are asked to open the page in maintenance mode, do so and try to add the web part from SharePoint Designer 2010. This was the case with a tasks list and may also apply to lists with workflows.
In the previous post, I talked about hidden lists and views and how you can use a web service to surface a number of list and view properties. In this post, I will outline the actual steps involved.
First, we will define two data sources in SharePoint Designer 2010 based on the SOAP Service connection: open the specific site in SPD, from the site objects navigation, select Data Sources. From the ribbon tab (data sources) select SOAP service connection. Provide a name on the General tab of the dialog and an optional description (we will call it Lists) and leave the Login tab as is. In the sources, enter http://site-address/_vti_bin/Lists.asmx?WSDL
Click the Connect button and select the GetListCollection item from the Operations drop down. Click OK to close the dialog.
Create a web part page and insert a data view based on the Lists source (Insert – Data View and find Lists under the SOAP Services category). We need to do this now as we will need to get a list id to initialize the second data source. Make sure the Name column is displayed (use add/remove columns if needed) and copy one of the names (including the curly brackets). Keep this for the next step.
Next, create another SOAP source and call it Views with address: http://site-address/_vti_bin/Views.asmx?WSDL and in the Operation drop down, select GetViewCollection. You’ll notice that it requires a parameter called ListName. Highlight the row and click Modify. Paste the Name you copied earlier in the default value box and check the box “the value of this parameter ..). Click OK twice to save the Views source.
Back on the web part page, add another data view based on the Views SOAP source. You should see one or more views belonging to the list you selected. Now, we need to connect the two web parts.
Select the Views web part and click Add Connection (from the ribbon) and select Get Parameters From on the first screen and click Next. Click Next on teh second screen and also on the third one (should have Lists and Send Row Data to). In the next screen, you are asked to match a field from the Lists web part to the ListName parameter. The item on the left reads “none”. Click it to select Name from the drop down and click Next. Keep Title as the hyperlink and check Indicate Current Selection Using, from the options (click modify) select ID from key columns. Click Next then Finish. Save your page and test it. Once you click a list title, its views are displayed and the title becomes bold. You can add/remove columns from either the Lists and Views dataform web parts and also control column order. Be sure to hide or block this page from unauthorized users. Notice that, unlike a REST service, a SOAP service can see the external list but it won’t report its item count (it shows 0). Although asmx services are on their way to retire, they can still be handy for several scenarios.
You may want to hide a list from the browser and the first thing you would do is to remove it from the quick launch. But, any one who can see All Site Content will find it easily. This is what SharePoint Designer is good at. Open the site in SPD, go to Lists and Libraries (from Site Objects), select your list and on the properties page, uncheck Show in Quick Launch and check Hide from Browsers. This way, the list will not show even if you try with All Site Content. You can still view the list if you know the url, of course, bit you can’t make it visible from the browser (trying to set it to show in Quick Launch will not stick and you need to go back to SharePoint Designer to undo the change).
For views, you can actually set the Hidden=”TRUE” property once you edit the view page in SPD (the <View Name=”" Type=”" source element). Hidden views are normally associated with web parts. If you turn a normal view (say you went to your list and created a new view) into hidden, you can’t see it even with SharePoint Designer on the properties page of the list. You can, however, ask a web service and sure, you will see hidden lists and views. In fact, SPD uses services to communicate with the SharePoint server.
In the illustration, I connected two xslt views (web parts) together. The first has all the lists in a given site and the second displays the views of the selected list.
Notice that the services retrieves many interesting properties for our lists – those funny GUIDs, item count, default view … etc. You can get some of these from the browser (all site content will give you list item count and you can spot list GUID in the URL), but this view looks handy.
Notice that this may expose some sensitive information, so you should keep the page you use to display this stuff away from public (ex. use special permissions).The services used here are the Lists.asmx and Views.asmx (the old web services). Notice that the ListData.svc does not see External lists (asmx service only sees what the browser does – it reports zero for item count). The actual setup of data sources and web part connection may be the subject of another post.