Monday, March 5, 2012

SharePoint Customization

When I tried to build site using sandbox, I found many restrictions. The better solution for most of these problems do a workarounds using out of the box controls and Web parts of the SharePoint.

I found site give us good solutions for building some modules with small customization of out of the box SharePoint Web parts and Controls with css and javascript functions:
It Contains solution for SharePoint 2007 and SharePoint 2010 Sample of them:
  • Color-Coding-Calendar-List:
    Display calendar with color depend on category of item in List
  • Pie and Bar Charts (Google Connector)
    Display chart using calendar chart depend on values in List
  • Easy-Tabs
    When added to a Web Part zone, the Easy Tabs automatically generate a tabbed interface, with one tab per Web Part present in the zone.
  • Cross-Site-List-Snapshot
    This script allows you to display in a SharePoint page a view taken from another site or site collection.
  • Tasks-Lists-Rollup:
    roll-up Web Part that displays items collected from multiple lists of the same type
  • Bookmarklet-Expand-Collapse-Web-PartsOn a SharePoint page:
    adds an expand/collapse button to each Web Part, next to the title.
  • Page-Redirect:
    This script allows you to redirect your users to another Web page (specified in the Target location), when they try accessing the current page.
  • Image-Rotator:
    The image rotator allows you to display on your page a picture randomly selected from a SharePoint picture library.

    You can use solutions and add more enhancement of it.

Create Poll for Sandbox or Office 365

I want to create Poll in Shared Environment that allow to create only components using Sandbox.
Sandbox has many limitation affect building this module:
  1. Cannot run component with elevated privilege or impersonate user. (Poll Component for anonymous users)
  2. Sandbox cannot serialize cookie only can read a cookie.

For these reason cannot build solution using sandbox to build a poll. Only Customize predefined controls using SharePoint Designer to build a poll.


  1. Create 2 Lists:
    • Poll List with Fields Question(Text), Answer1(Text), Answer2(Text), Answer3(Text), Active(Yes/No)
    • Poll Result QuestionId, Answer1Count(Number Default 0), Answer2Count(Number Default 0), Answer3Count(Number Default 0)
  2. Create Workflow When you add a Poll Item in List It will add item in Poll Result.
  3. Give Add Permission of anonymous user in Poll Result.
  4. Create Active Workflow to allow only one active poll. If We activated Poll, Deactivate others.
  5. Create DataView For Displaying a Poll:
  • DataSource read the 2 lists read active poll and its results.
  • XSLT contains 2 View:
    1. Show Poll and allow user to vote. Appears if user didn't respond on this poll.
    This contains form question as title and questions as radio buttons in Forms and button for respond.
    When user click button. It will call client object model to increase selected answer count. and set cookie using JavaScript using jquery that he answer this question.
    you can use captcha using javascript:
    2. Show Results display Poll Result. . Appears if user respond on this poll.
    Validation that user respond this answer check if active poll Id exists in cookie that set in previous step. You can build graph for displaying results using div and style sheets.

This is simple Poll for sandbox or Office 365 you can add more enhancement.

Saturday, March 3, 2012

SharePoint 2010 Sandboxed limitation

SharePoint 2010 define a way of packaging called sandbox because old way of packaging is not suitable for shared environment. If there is a problem of package it will effect the environment. But new packaging technique will effect only sandbox's modules was deployed in this site collection.
Components of the sandbox:
  • User Code Service (SPUCHostService.exe). This is responsible for creating the sandbox worker processes that execute individual sandboxed solutions and for allocating requests to these processes.
  • Sandbox Worker Process (SPUCWorkerProcess.exe). This is the process in which any custom code in your sandboxed solution executes.
  • Sandbox Worker Process Proxy (SPUCWorkerProcessProxy.exe). This provides a full-trust environment that hosts the SharePoint API. This enables sandboxed solutions to make calls into the subset of the SharePoint object model that is accessible to sandboxed solutions.

But Sandbox has many limitations:

  1. You can use most of SharePoint API but you can only use current site collection. All you information must be saved in current site.
  2. No Security Elevation (You cannot impersonate). You can only run with current logged in user. You must give a user actual permission to access SharePoint item.
  3. No Email Support (You cannot send email). Only workaround start workflow with activity to send the mail but take care of needed permission to start workflow.
  4. You cannot use SharePoint Web Controls.(You can use asp net controls instead of it).
  5. You cannot do WebRequest connections,(http, web services, wcf, and etc). To access those use through javascript or silverlight.
  6. No GAC Deployment (Sandbox solutions are not stored in File System, they are stored in the database) C:\ProgramData\Microsoft\SharePoint\UCCache temporary for global assembly cache.
  7. Enterprise features (Search, BCS, etc.) are not allowed.
  8. CAS does not allow you to access database. All data storage in SharePoint List.
  9. CAS does not allow you access IO:
    • Global folders like “_layout” & “resources” are not authorized. To use resource file embed it in the dlls.
    • No Visual Webparts
    • No Custom workflow
    • Allow features depend on physical files are not allowed.
  10. No Threading.
  11. No P-Invoke
  12. Sandbox work in separate domain and initialize new page serialize some information to communicate with w3wp.exe.
    Serialized Information which can use in sandbox:
    • ID's of Form, Web Part Manager, Zone, Toolpane
    • Web Part properties
    • Options and properties of the Web Part and zone, such as chrome, zone customization, width, height...
    • View state
    • Control state
    • Server Variables (except APPL_PHYSICAL_PATH and PATH_TRANSLATED)
    • Request Headers
    • Input Stream
    • Current context (List Id, Item Id)
    • Query String

    Serialized Information which can use in sandbox:
    • The Cache object
    • Cookie
    • The ScriptManager or callback
    • The ClientScriptManager
    • The HttpRequest.Files collection (work with limited size to 128KB
    • The Master Page
    • Embedded resources (these are requested by the WebResource.axd and they cannot resolve the Sandboxed assemblies from the W3WP.exe process)
    • You cannot use redirection (Response.Redirect, Server.Transfer or SPUtility.Redirect)
    • You cannot export a Sandboxed Web Part (it will just export the SPUserCodeWebPart)
    • Also you cannot access page object (you cannot control hide or show controls in page like HideCustomAction and CustomActionGroup)
  13. PropertyBags of SharePoint Object model are not accessible
  14. ASP.NET 2.0 web controls are not fully working (those that are using “WebResource.axd” for internal binaries resources, as .axd extension is not allowed). Instead of embed them upload to SharePoint and refer to them as external resources.
  15. Also Sandbox limited number of resources used and deactivate sandbox solution if they reached limited number of resources. limitation depend in number of point limitation by administrator and calculated as this table:

    Metric Name



    Resources Per Point

    Hard Limit


    Process gets abnormally terminated





    CPU exception time





    Critical exception fired





    Number of times solution

    has been invoked





    Note: # of cores not factored in

    Percentage Units of Overall Processor Consumed




    CPU Cycles




    Windows Handles




    (Hard Limit Only) Bytes written

    to IO





    Number of Threads

    in Overall Process





    (Hard Limit Only)

    Memory consumed





    SharePoint DB Queries Invoked





    Amount of time spent waiting

    for a query to be performed





    Unhanded Exceptions




    We have to kill the process because it has become unresponsive




    For more details check URL: