Tuesday, October 26, 2010

Calculated columns cannot contain volatile functions like Today and Me

When you trying to add calculated formula in list based on current date. You add '[Today]' in your formula and you give error like:- "Calculated columns cannot contain volatile functions like Today and Me". See image below:-




To solve this error use following steps:-

  1. Open up the List Settings page where you want this column.
  2. Create column named “Today”. The type doesn’t matter here, so let type as “Single Line of Text” and just click “Ok” 










3. Now create the calculated column where you need to use current date within formula and add “Today” from available columns.


















4.Once this is done, we no longer need that our own generated column “Today” so you can delete it (Although when you need to edit formula you will need this again, so either recreate this dummy Today field or make it hidden using code behind. Otherwise SharePoint will put you again on that error screen).






5.For calculated fields, calculated value is stored in Database when item is created at first time and doesn’t change until item is edited. So using Today doesn’t means each time you will get value re-calculated as per actual today’s date. For that it is better to use Computed column.

Thursday, October 21, 2010

"Errors were found when compiling the workflow.The workflow files were saved but cannot be run."

When you create workflow using sharepoint designer tool and you get the following error:-

 "Errors were found when compiling the workflow.The workflow files were saved but cannot be run." and if you click on details button you get message "Unexpected error on server associating the workflow".

The problem with your web.config file. If you install some third party workflow tool(e.g Nintext,Sogeti,EdinKapic) and unistall it, referrence dll not removed from your web.config file. 

To remove error use following steps:-
  1. Open your web.config file in Visual studio.
  2. Go to "<System.Workflow.ComponentModel.WorkflowCompiler>"
  3. The third party workflow tool reference available here. e.g. Sogeti.Workflow tool
  4. <authorizedType Assembly="Sogeti.Workflow.Activities,Version=1.0.0.0, Culture=neutral, PublicKeyToken=1cdaea2144644b9c" Namespace="Sogeti.Workflow" TypeName="*" Authorized="True" />
  5. Comment the third party tool reference, you uninstall previously.
  6. Save web.config file and reset server.
  7. Now your workflow run normally.

Saturday, October 16, 2010

Difference between SPWeb.Users, SPWeb.AllUsers, SPWeb.SiteUsers

SiteUsers,  AllUsers and  Users are properties of SPWeb Object. But looking to this properties name,  its not easy to understand their’s scope.  So below is description about this properties:-



  1. SPWeb.Users :- This represents the collection of users or user objects who have been explicitly assigned permissions in the Web site . This does not return users who have access through a group.
  2. SPWeb.AllUsers :-This gives us the collection of user objects who are either members of the site collection or who have atleast navigated to the site as authenticated members of a domain group in the site.
  3. SPWeb.SiteUsers :- This is the collection of all users that belong to the site collection.