April 10, 2013

SharePoint 2010 List Throttling

Filed under: Best Practice, List Throttling, SharePoint 2010 — Tags: — Agamand The True @ 4:51 am

SharePoint introduces List Throttling feature in SharePoint 2010 because of SQL Server Locking mechanism. This feature is also a solution for the farm admin to overcome the performance issue  (preventing performance degradation) associated with large list.

  1. When querying more than 5000 items, SQL Server will escalate the locking level from row-level to the table-lock level.
  2. This means that any subsequent query request to that table will be blocked, hence no concurrency possible.
  3. One of the 6 pillars of SharePoint 2010 is Collaboration which is all about sharing resources and working together.
  4. So if there is no concurrency due to the SQL Server locking mechanism will lead to no collaboration which defeat the main purpose of SharePoint.
  5. There are quite number of ways to overcome this problem. Below is the approach available for developers.
    • Identify which site is that need to have more than 5000 list items, isolate that site by creating that site in a new site collection with its own content database. Disable the list throttling property of that list by setting SPList.EnableThrottling = False (use powershell script). Educate the users of this site that they may encounter issues such as slowness when performing operation on that list.
    • Use folders, distribute the list item in the target list into folders (preferably 2000 items per folder). Since folder is indexed by SharePoint, it will not hit the list throttling issue. User can do the CRUD operation using the out of the box list form of that list. To search the entire list items in that list , need to create a custom solution (application page or webpart). Setup the query and then set the SPQuery.ViewAttributes = “Scope=’Recursive’”. Make sure to set the RowLimit to 2000. This way, we will get the results in 2000 item per batch by combining the use of ListItemCollectionPosition. This site got the detail . Another object model we can use beside the SPQuery and the ContentIterator
    • Elevate the query to run under the user account of the Farm Administrator.
  6. For the Administrator, Central Admin is your friend.
    • Go to the Central Admin –> Manage Web Applications –> Click on the target web application –> click on the General Settings –> from the drop down select the Resource Throttling option
    • listThrottling
    • You will be presented will a number of options to overcome the list throttling such as increasing the number of items
    • settings
  7. One last option and the option that should be set very early when provision a list is by using Index. The reason is that, once the list items reached 5000 items that it will too late since you cannot index a column anymore due to the list throttling.
    • the ID column is always index by SharePoint. So we can query based on the ID index such as return the first 1000 items sorted by the ID field.
    • If we have indexed other columns, lets say the Title column then we can perform the same query mentioned above but this time sorted by the Title column.
    • We can have up to 20 indexed columns in a list.
  8. Remember, once a list contains more than 5000 list items then performing the below operation on that list will throw the list throttle error (get more detail here).
    • Reading list item (without using indexed column and setting the row limit)
    • Deleting an item or folder
    • creating index
    • Deleting a site
  9. Below is all those great blogs that I got my information from.

SharePoint is GREAT!


March 24, 2013

Manage Content And Structure, Value Cannot be null Parameter name:g

Filed under: SharePoint 2010 — Tags: , , — Agamand The True @ 9:14 am

This post was published to DotNetAdil at 15:06:36 24/03/2013

Manage Content And Structure, Value Cannot be null Parameter name:g

1. I came across this problem when trying to move a page in a Publishing site to another site (subsite) in the same site collection.

2. The move operation was done using the OOTB feature of SharePoint called Manage Content and Structure.


3. This is really a great tools to move things around SharePoint, for example to move a page in the Pages library from one site to another I just need to setup the target site.

4. To setup the target site, create a new site under the source site using the Publishing site template and that’s it. (since in my case I’m moving publishing page).

5. SharePoint will take care of the content types and field synchronization from the source site to the target site.

6. Below is the error that I faced when I try perform the move operation.


7. Upon clicking on the View Logs I found the following error message.


8. Parameter name:g Value Cannot be null appears twice.

9. After googling around I found this site which explain why this thing happens.

10. It has something to do with the field definition (xml) of a User type.

11. After digging around the source (Pages library), I found out that there are 2 custom fields of User Type added to the Content Type that the page is using.

12. These fields was provisioned through XML (Visual Studio) and both the field definition doesn’t include the List="UserInfo" attributes.

13. To add this attributes to the both Fields, I’ve created a script like below.


14. Once this script completed running, I move the page again and this time it was successful.

15. The script above will add the attribute at the library level fields or columns, to avoid this thing (error) from happening again in the future it should be added at the site column.

16. To learn more about Manage Content And Structure tool, go to this site.

17. To learn more about the Content Deployment And Migration API which the tool is using, go to this site.

SharePoint is GREAT!

Updating deployed content types in SharePoint 2010

Updating deployed content types in SharePoint 2010

1. Content types can be created via the UI (Site Settings -> Site Content Types), Object Model and XML

2. Updating an existing content types created from the UI and Object Model is fairly simple and straight forward.

3. To update an existing content type created from XML (Visual Studio) needs us to understand SharePoint 2010 ALM

4. Let’s say you created a XML based content type using Visual Studio like below:-


5. Once deployed you can updates this content type (in this XML) like adding new fields and redeploy it again. SharePoint will just read this xml and updates any changes it found.

6. Once you associate this content type to a document library or in other words created a List Content Type from this Site content type, SharePoint will not update any changes done to this xml.

7. Below are the test I’ve done to prove this:-


8. To update a Site Content Types that has one or more List Content Type, SharePoint provide something called Solutions Lifecycle Management

9. This is what Solutions Lifecycle Management is all about – “The SharePoint 2010 solution packaging model provides many useful features that will help you plan for deploying custom solutions and managing the upgrade process. You can implement assembly versioning by applying binding redirects in your web application configuration file. You can also apply versioning to your feature upgrades, and feature upgrade actions enable you to manage changes that will be necessary on your existing sites to accommodate feature upgrades. These upgrade actions can be handled declaratively or programmatically.”

10. In our case, we will be utilizing SharePoint 2010 Feature Upgrade Actions.

11. Below are the steps:-

a. Open up the existing solution that you wants to update.

b. Define a new field in the solution


c. Open up the YourFeatureName.Template.xml file in the feature folder and add the xml below


d. Notice the red arrow above, you need to upgrade the feature version. See below


e. Add an Event Receiver to the feature


f. Open up that event receiver files, uncomment the feature activated and feature upgrading events. Put in the code below:-


g. Now you can build and package your solution.

h. The last step is to deploy it or more precisely, to upgrade the existing solution.

i. For that use the SharePoint cmdlets for updating solution which is Update-SPSolution

j. Remember don’t deploy the solution, we need to fire the feature updating event receiver.

To know more about this subject refer to the site below:-

SharePoint is great!

January 22, 2013

June 27, 2012

SharePoint and Multithreading

  1. Thread is an independent execution path; it can run side by side with other threads.
  2. By default a program will run on one main thread, we can add additional threads by leveraging System.Threading class.
  3. Since a thread is independent of other thread, it is perfect for updating list operation since we need to elevate our code (runs it in a new context) in order to successfully perform any updates to a SharePoint list (see below screen shot).

  4. I had two operations that need to be executed on a click of a button, one is to create a new item in a SharePoint list and the other one is to send email.
  5. I can speed up the process by adding one more thread to handle the item creation process and let the main thread to carry out the send email operation as you can see below.

  6. I wrap my target code with SPMonitoredScope so that I can see the performance between running the code sequentially (one thread) and running it in parallel (multithread).
  7. Through the Developer Dashboard here is what I get :-
    1. One thread (sequential)

    2. Two threads (parallel)

  8. The difference is not that great, but still a dollar saved is a dollar earned.
  9. To know more about Multithreading in C# go here and for the monitoring go here

    SharePoint is Great!!!.

May 29, 2012

SharePoint Designer Approval Workflow

  1. Following the previous blog (SharePoint Foundation Visual Studio Approval Workflow ), the same workflow can also be done using SharePoint Designer. The only difference is that in Visual Studio based workflow, no code elevation is required since the workflow always runs under the System Account. But in SharePoint Designer, the workflow always runs under the user who triggered the workflow.
  2. So, obviously in our case (Set Approval status) the user must have the permission in the first place otherwise the workflow will get error (Access Denied).
  3. We can get around this issue by impersonating our step like below :-

  4. The above step can be achieved by clicking on the button located in the SharePoint Designer context sensitive ribbon bar (see below).

  5. Only then the workflow will always run under the account that created the workflow and not the user who triggered it (as you can read in the description).

SharePoint Foundation 2010 Visual Studio Approval Workflow

Filed under: SharePoint 2010, Visual Studio, Workflow — Tags: , — Agamand The True @ 10:12 am
  1. The scenario is that a document library has a column of type option named WorkFlowLevel. Level -0 means that the document is approved automatically by the uploader and Level -1 means the document can only be approved/reject by a person who is in the Approver groups.


    Approver groups

  2. The final workflow is as below:-

  3. To create such solutions fire up the Visual Studio and select a Sequential Workflow template, and set the solution settings as below

  4. First code is to define the OnWorkflowActivated event .

  5. Then connect this method to the activity on the designer

  6. Next go to the Toolbox, under the Window Workflow v3.0 tab drag and drop the ifElse activity just below the previous activity and then define the code to execute.

  7. Associate the above code to the left if branch (if the condition return true then this side will fire, if it false the right side will automatically fire)

  8. If true, the left side will execute a code (see below) that will email a document approval request to all the member of the Approver groups

  9. Drop the send email activity and associate the above code.

  10. Now we are going to use the while loop that will loop until the Approve Status is equal to Approved or Reject.

  11. Associate the while loop with the code below

  12. Inside the while loop drop the OnWorkflowItemChanged activity and then define the code before associating the two.

  13. When the document have been approved or rejected, the loop will break where based on the status we will send the email to the document creator. Drop the ifElse activity just below the while loop.

  14. Below is the email code for sendApprovedEmail

  15. One last part of the workflow is the right hand side, where the document does not require any approval. The approval status is automatically set to Approved.
  16. For that, just drag and drop the Code activity from the Toolbox inside the else activity and associate the ExecuteCode.

  17. To approve a document, the user needs to have at least Design permission level. Even though the workflow can be triggered by user that has permission other than Design which by right the code should be elevated. Here we are not elevating anything since unlike SharePoint Designer workflow which runs under the user
    who triggers it, a Visual Studio workflow will always run using the System Account (that means Full Control).
  18. Oh, by the way the link in the email will open the below page (Item Display Form).


May 16, 2012

SharePoint MasterPage – different masterpage for different site pages

  1. When a new site is created, SharePoint (Foundation) will provide 3 masterpages that will have its own purpose.
  2. You can see this masterpages by going to SiteAction -> Edit in SharePoint Designer

  3. Your site now will be open in SharePoint Designer and by clicking on the Master Pages link in the Side Objects pane, you’ll see the three OOTB master pages provided by SharePoint

  4. OOTB master pages.
    1. default.master – is for backward compatibility, SharePoint 2007
    2. mimimal.master – is for search page
    3. v4.master – is for SharePoint 2010
  5. When you right click on the v4.master, you’ll find that both Set as Default Master Page
    and Set as Custom Master Page is greyed out. Because v4.master is set as those two (Default and Custom) by default.

  6. This gives you a chance to create your own master page and set it to either Default or Custom so that you can swap it easily.
  7. For example I added my own master page called SharePointWaves.master and set it as the Custom Master Page. You can upload a master page by going to Site Action -> Site Settings and click on Master Page under the Galleries header.

  8. From the image below you can see that I’ve set v4.master as the default and SharePointWaves (mine) as the Custom. The option (default or custom) will be greyed out once you set it.

  9. To change the masterpage for a Site Pages, just open the target site pages and find the MasterPageFile property and change it to default.master or custom.master.

  10. The Home.aspx with custom.master

  11. And here, Home.aspx with the default.master

  12. The whole point of this article, is to show that how simple it is to have two masterpage that are interchangeable just by setting the MasterPageFile property to either default.master or custom.master via SharePoint Designer

April 30, 2012

ASP.NET custom validator – client side

Filed under: ASP.NET, Validation — Tags: , , — Agamand The True @ 6:46 am
  1. To validate an dropdownlist client side

  2. The javascript code

April 11, 2012

SharePoint Item Deleting Event Receiver Deny Delete

Filed under: Custom Development, Event Receiver, SharePoint 2010 — Tags: , , — Agamand The True @ 6:41 am
  • Let’s say you have a requirement where an item in a document library can only be deleted by the uploaded and by someone from the Owner group.
  • The objective is to prevent other user from deleting each other item.
  • This can be accomplished via the ItemDeleting event receiver.
  • Below is the code to do so.

  • Note the DoesUserHavePermission method of the SPWeb object; this will make sure that the user is in the Owner group.

    Hope this helps.

Older Posts »

Blog at