Archive

Posts Tagged ‘conditional formatting’

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

Conditional Formatting Based On A lookup Field

June 1st, 2011 Abed Khooli No comments

I will not explain conditional formatting here as you can easily find plenty of literature on how to do that. You can format a row or a column (or show/hide content) based on a certain rule or condition. Conditions can be simple or complicated and can comprise comparison and Boolean operators. There is an issue when you try to based your condition on a lookup field (field referenced from another list).
Let’s say we have a list and one of its columns (status) is a lookup to a different list. We want to highlight the status cells (column) when the status is either empty or ” Rejected”. You may say well, click inside one of the status cells in a listview (xsltlistview), select conditional formatting, format column (from the ribbon in SPD), and in the criteria dialog, you set status is null or status equal Rejected. You select your format (reddish background in this example) and test it. You will notice that empty cells were picked but not those with value equal to Rejected. What;s the problem?
Well, internally, the lookup column is not stored as we think it is. In fact, I created this example using a service as a data source so you can see what I am talking about (this is why it has those funny column headers) – the status is stored in the format: “number;#value” and this is why the equal operator will not work. This is not too bad, actually. We can use contains instead and it’ll work just fine. The number is the ID of the item corresponding to the selected value (they happen to be in order in this example just by accident!). Also, you won’t make a new list to store a few status values – this is just an illustration. Finally, make sure, when debugging your conditional formatting, to use easy to spot changes like backgrounds or fonts. Some styles like borders may be overridden by the SharePoint styles!
There are other cases where a similar format is used: multiple selections, user fields and managed metadata, so beware.

Categories: SharePoint Designer 2010, SharePoint Server 2010, Web Parts Tags: ,