Archive for the ‘Libraries’ Category

How To Identify Unpublished Documents In A Document Library

July 8th, 2011 Abed Khooli No comments

If you have versioning turned on in a document library, including minor versions, you have to publish a major version for your latest editing to be visible to other users. This is the normal draft security settings, which can be changed, but should not. So, how do you recognize your unpublished documents without going into version history?
Well, you could add the Version column to a view which filters on current user [Me] for the Created By column (or may be Modified By if you allow editing of others’ documents). A user can spot versions with a decimal number and take action. Now, what if you want to add some visual indicator? Conditional formatting to the rescue!
Open your view in SharePoint Designer (Version should be one of the columns in the view, if not just add it (list view tools – options – add/remove columns). Select one of the version values and click Conditional Formatting then Format Column (or Row, if you want). In the Condition Criteria dialog, click the Advanced button and enter the following condition:
ceiling($thisNode/@_UIVersionString) != floor($thisNode/@_UIVersionString)
Select/configure your preferred style and save. Your unpublished documents should now be outstanding. The version column may be helpful especially for document authors, but if you selected to format the whole row (ex. background color), you can get rid of the Version column in the table. To do so, highlight the column, go to Table (list view tools) and select Delete/delete columns. Do not use the add/ remove columns!

Categories: Libraries, SharePoint Designer 2010 Tags: , Unpublished Versions

List Of All Lists In A Web Using ListOfLists DataSourceMode

June 8th, 2011 Abed Khooli No comments

I wrote earlier about using a SOAP service to get an inventory of lists within a certain site. This post uses a different approach and can also be filtered for a particular type of list. So, if you need to view all task lists or calendars or document libraries or surveys or even external lists based on the __spBaseTemplate property.
The approach is fairly simple. Create a web part page in the relevant site and insert an empty data view (insert – data view – empty data view). You will get a link to select a datasource and you can select any list (in this example, the Links list was selected – random selection). You have a few fields selected in the data source details pane to the right, so you just select the “Insert selected fields as …” and choose Multiple Item View from the drop down (this is in the data source details pane near the top, select view/data source from the ribbon if the datasource is not visible). You should see some rows if the selected list is not empty.
Now, switch to code view (bottom left of the status bar) and locate the List” fragment of the code and change List to ListOfLists and switch back to design view.
You may notice something strange: a grid with several rows and no data inside. That’s ok. We’ll fix soon. While the dataform web part is selected, go to Add/Remove columns from the ribbon (data view tools – options tab). Remove the select fields (right side) and select a few of those starting with 2 underscores (__). Enlarge the image of the example to get a few to start with (I did not rename them for illustration, you should). In the Paging option (next to add/remove columns), select Display all items. That should give you a list of all lists (libraries included) within the site.
if you want just a specific type of list, click Filter (ribbon options) and then from the filter dialog, check add XSLT filtering and click Edit to add your filter. For example, use [@__spBaseTemplate='ExternalList'] to get only external lists.
You can adjust to dataform view, link lists or conditional format as you need, including the title of the web part which is named after your selected list by default. Notice that this works within one site (by default, the site you created the page in).

Categories: Data Form, Libraries, Lists, SharePoint Designer 2010 Tags: ListOfLists

How To Display Documents From Different Libraries Using DataView

June 4th, 2011 Abed Khooli 8 comments

The content query webpart (CQWP) is usually used for content rollup across a site collection and it is very powerful, but it is not easy to customize and style. Using a dataform webpart with some tweaking can do the trick (and you have to use SharePoint Designer 2010 to do that).
A blog article titled SPDataSource and Rollups with the Data View is the starting point here. You basically edit the data source in source mode to enable cross list fetching of items and specify what kind of list you want to include. Lists (and libraries) have something called ServerTemplate id or value and you can find these here. A document library has value = 101.
So, here’s how we start: add a web part page and insert an empty data view (insert – data view – empty data view). Click to add source and select a document library. In this case, I selected Shared Documents in a team site (and I also have a blank site under it with another document library called blankdocs). Then, inserted the datasource selected fields as multiple item view. I added a filter (from options) to include items with title that contains the word “Policy” and also selected which fields to show and items per page (all items).
Now, switch to source mode and find the datasource tag (if you had the view selected, you get the corresponding source highlighted). You need to change DataSourceMode=”List”  to DataSourceMode=”CrossList” and in the selectcommand add <Webs Scope="Recursive"></Webs><Lists ServerTemplate="101"></Lists> inside the tags. Notice that the < and > are replaced with their own literals. This should get the items, but how do you link to the documents themselves? Well, select one of the titles, right-click and select Format as .. hyperlink. Keep the Text To Display as is and in the address, put {concat(‘/’,substring-after(@FileRef,’#'))} and you are done. You can clean up other fields or format them differently or even do conditional formatting. Documents come from any library in the site collection meeting the criteria. You cold do the same for other types of lists (remember to use the correct ServerTemplate value and adjust links.

SPDataSource and Rollups with the Data View

Categories: Data Form, Libraries, Lists, SharePoint Designer 2010 Tags: CrossList, dataview rollup, display documents from different libraries

Mass Manipulation Of Multiple Values Lookup Field

June 3rd, 2011 Abed Khooli No comments

Here’s the scenario (was actually a question on the SharePoint forums, but we are making it more complicated here): you have a list or document library with one lookup field that allows multiple values. You have a few tens of items and you remembered you should tag all items with one additional value from the lookup list. Now if you can base a calculated column off a lookup field then this is all you need, but life is not that easy with lookup fields as they tend to store their values internally in a special format as we saw in the previous post (Conditional Formatting Based On A lookup Field). We can do that using the datasheet view and a couple temporary columns.
First, we need to get the contents of the lookup field, so we create a single line text field and switch to datasheet view and copy the lookup field values into the text field (that’s copying MyStatus into TempValue in our example). Now, we have the values of the lookup field in a normal field and can do calculations. Add a new field as calculated field based on TempValue. The formula is: =IF(COUNTA(TempValue),TempValue&”;#Add me;#4″,”Add me;#4″)
Notice that this takes care of empty fields (like our first item) and it follows the trend of how the lookup field is stored internally (if it is the only value or not and uses the ID of the choice from the parent list – in this example “Add me” was item ID 4 and you can try to add it manually to one item to get that). Now you do have the correct column but it is not the lookup field you need to fix. All you need to do is to switch to datasheet again and copy the calculated field over the lookup field and it gets formatted normally. Of course, you do not need the two fields you added anymore, so back into list or library settings and delete them.

Categories: Libraries, Lists, SharePoint Server 2010 Tags: , multiple value lookup column

How To Rename All Files In A SharePoint 2010 Document Library

May 10th, 2011 Abed Khooli 1 comment

In the previous post, I talked about an alternative way to looping in SharePoint Designer 2010. Let’s say you have uploaded a few hundred documents into a document library and then you did not like the file names – for example, most of them have a space you want to get rid of, or even worse: a comma.
If you can access a network share with required security and other business rules, you may put the library in Windows Explorer view, map to a network share and use a standard file re-naming utility (or even run a command line or Powershell). Otherwise, you can use code and batch process the library. But if you only have access (and rights) to SharePoint Designer 2010 in addition of your SharePoint site, you can still do it. Our example library has documents (ex. CVs) named something like “smith,john.docx” and you want to rename it as “smith_john.docx”.
First, create a temporary text column (TempName) and a calculated text column (NewName). NewName replaces commas from TempName with underscores. Here’s the formula (one comma – the first one):
Why not just use the Name field? Well, you do not have access to it from SharePoint, but SharePoint Designer 2010 can get it. SO, we create a workflow against our library that: 1. Update the current item by setting TempName to Name (for use in forms) – which is the name without extension. 2.Pause for a while (1 minute) – to make sure the item has updated. 3. Set the Name field to the NewName (which should have been calculated since TempName has changed).
In the WF settings, check the Start WF when item changes. Check for errors, save and publish. Use the previous trick to trigger all item change and your workflow will do its work. When done, remove the workflow and also remove the three fields (TempName, NewName and the dummy column you added to for auto-fill). You should not do this during peak time and could do it several times if you want to get rid of more than one character per name.

Categories: Libraries, SharePoint Designer 2010, SharePoint Server 2010 Tags: Rename files