Thursday, December 10, 2009

PDC 2009

Hi all,

Microsoft has released PDC sessions which inculdes:
  • Videos
  • iPod & iPhone pod casts
  • Slides (Powerpoint)
as I too keen with respect the SharePoint 2010 development and administration, Mike Ammerlaan (Product Manager, SharePoint foundation at Microsoft) has dealt with new programming concepts and paradigm.

Overview of SharePoint 2010 Programmability

He talks about:

  • Comparison for SharePoint 2007 vs SharePoint 2010
  • SP2007 Web Part vs SP2010 Web  Part designer 
  • Easy way to create lists with AJAX framework.

    Lists and Libraries
  • SharePoint is web-file system. It has folder structure, it has files and on top of it, it has site model. In the hierarchy, we have lists, folder and we code against them. 
  • Sites can have lists and libraries.
    >> Fields and List items.
    >> Lookups provide simple join semantics
    >> Queries within and across lists

  • New to the SharePoint 2010
    >> Lookup to multiple columns
    >> Relationships and joins available as well
    >> Validation
    >> Scalability, performance and throttling.

    The concept of list throttling is exciting and users can add more than 20, 000 items.
  • Concept of List throttling, connecting multiple lists using the relationships, scalability and performance.  
  • List validations such as email, integer validations etc., lookup to multiple columns 
  • Connect lists with external databases such as SQL servers.They work seamlessly with SP2010 and we can easily manipulate the lists as if we are real lists and views. Relationships comes with cascading delete and restrict delete functionalities.
  • SharePoint 2010 has really structured the lists and schema in proper way.
     
  • Introduction to the SPLinq.
  • Introduction to the Client APIs for SharePoint 2010

    Events:
  • With lists, we also have list events and item events.
  • In SharePoint 2010 we have new events such as
    >> After-synchronous events (simpler event behavior)
    >> Site-scoped events
    >> Web creation events
    >>  List creation events
    >>  Workflow events
    >>  More user interface control (custom error pages)

They are overwhelming volume of videos from PDC sessions from Microsoft and its a boon to the world of developers.

Please click here to get more details.

Cheers,
--aaroh

Friday, November 27, 2009

How to: Out of box Approval Workflow issue and solution - Part 2

Hi all,

If you have noticed that SharePoint Approval workflow, you will get an issue. Please refer to my part 1 blog.

PROBLEM:
Apparently, when an item is attached to Approval workflow to control content approval for a user with contribute permissions, they can approve their own major version of an item through the approve button in the workflow.

There a no way to configure the workflow so the site members (contribute permission level) can not approve their own major versions of an item. Its really a MAJOR drawback of out of the box Approval Workflow. 

For e.g.  
Suppose we have a document library called as "Business Services". We attach an OOTB SharePoint "Approval" workflow to it. Permissions to this document library has 2 users:
i) vm\local1 (with contribute permissions)
ii) vm\approver (with approver permissions).

Testing for vm\local1: 


>> vm1\local1 logs in.
>> Goes in to "Business Services"
>> Uploads a document.
>> Check in the document, right click and choose "Publish a major version"
>>  Approval workflow kicks in. local1 enter the approver name and hit the "Start" button.
>> This document will be in "Pending" status and workflow status will be "In Progress".
>> a) Right click on the document, choose the "Approve/Reject" from the ECB. We will receive Error Access Denied. EXPECTED BEHAVIOR
     b)  Click on the "In Progress" link, Go to the task list, try to approve this document. Approval workflow will be completed and version 1.0 approval status "Approved". NOT EXPECTED BEHAVIOR


Workaround: 


In my previous blog, I had NOT touched the OOTB Approval workflow, but I changed TASK list's behavior. But in that blog, actually checking the permission for the TASK and not for the "Business Services". In this blog, I corrected the behavior. This time, I have verified permission for "vm\local1" on the "Business Services". 

My Task's event handler: 


public override void ItemUpdating(
SPItemEventProperties properties)
       {
           base.ItemUpdating(properties);

           this.DisableEventFiring();

           using (SPWeb currentTeamSite = properties.OpenWeb())
           {
               // Delcare variables/Objects
               bool isApprover = false;                            //Flag to check permission
               string currentUser = string.Empty;              //Get current user (For e.g. vm\local1)

               // Get the current item
               SPListItem currentItem = properties.ListItem;

               /* STEP1:
                   We need to get the current logged in the user. In our case, its vm\local1. Bear in mind that, we have hooked the "TASK" list as the event handler. through event properties we can extract the current logged in the user
               */

               // Get the value display name of the current logged in user and Created by Field of the current item
               currentUser = currentItem["Author"].ToString(); // For e.g. 21;#vm\local1
               SPUser user = currentTeamSite.AllUsers.GetByID(properties.CurrentUserId); // extract the ID. such as 21

               /* STEP2
                   THIS PART THE MOST IMPORTANT PART OF THE CODE. We get the currentUser. But we need to parent list which is "Business Services" and get the permission for the user on that document library. In the task list, we always have reference to the workflow.  Therefore, currentItem has workflowListId and through which we can get the parent list.
               */
                  // Get the Parent list (such as Business Services, Development etc. currentItem is from Task lists)
               SPList parentList = currentItem.ParentList.ParentWeb.Lists[new Guid(currentItem[SPBuiltInFieldId.WorkflowListId].ToString())];
          
               /* STEP3: 
                  Now, we have to get permission of current logged in user on the "Business Services".
               */
               // Get the permission of current user for the "parentList"
               foreach(SPRoleDefinition definition in parentList.AllRolesForCurrentUser)
               {
                   Console.WriteLine(definition.Name);
                   if( (definition.BasePermissions & SPBasePermissions.ApproveItems) != 0)
                   {
                       isApprover = true;
                       break;
                   }
               }        

                /* STEP4:
                    If the current logged in user has "Contribute" permissions, then we show an error message to the user.
                */

                // if user is NOT an approver show the error message
               if (!isApprover)
               {
                   properties.Cancel = true;
                   properties.ErrorMessage = "You dont have access to this operation because of your access rights.....";
               }
           }

           this.EnableEventFiring();
       }


 Cheers, 
--Aroh


Reference: 
Geek hubkey
Social MSDN SharePoint forum


How to: Converting List Item to SPUser object

Hi All, 

Many times we need to cast a list item to a SPUser object. It can easily done using these steps: 

Step1: Get the current item
SPListItem currentItem = properties.ListItem; 

Step2: Get the value display name of the current logged in user and Created by Field of the current item
currentUser = currentItem["Author"].ToString();

Step3: Get the user id as integer
int userid = Convert.ToInt32(currentUser.Substring(0, currentUser.IndexOf(";#")));

Step4: Convert SharePoint user which matches the ID
SPUser user = currentTeamSite.AllUsers.GetByID(userid);

There is one more case where we have number of users. In this scenario, 
we can loop the users: 

--------------------------------------------------------------------------------
// get a reference to the "Alerts" list as an instance
 SPList alerts = spWebRoot.Lists["Checklists Alerts"];
 
// get the query object for user alert
 SPQuery queryUserAlert = new SPQuery();
 
queryUserAlert.Query = "<Where>" +
      "<Eq>" +
               "<FieldRef Name='Team' />" +
               "<Value Type='Choice'>" +    teamName + "</Value>" +
       "</Eq>" +
 "</Where>";

 SPListItemCollection noOfUsers = alerts.GetItems(queryUserAlert);

//Get all the users in that team (such as Desktop Support - Daily)
foreach (SPListItem item in noOfUsers)
 {
        //Use "GetUser" function for List "item" into a SPUser ojbect 
        SPUser user = GetUser(item, item.Fields["User"]);

        // REMAINING LOGIC
} 


private SPUser GetUser(SPListItem item, SPField userField)
 {
     string currentValue = item[userField.Title].ToString();
     SPFieldUser field = (SPFieldUser)userField;
     SPFieldUserValue fieldValue = (SPFieldUserValue)field.GetFieldValue(currentValue);
      return fieldValue.User;

  }

Happy programming, 

Cheers
--Aroh 

Thursday, November 26, 2009

Bug on SharePoint Server 2007 SP2 and Hotfix

Hi All, 

PROBLEM:
If we try to update the SharePoint 2007 service pack 2, you may encounter an error: 
"Trial Period Expired"

Apparently, we are using Project Server 2007 and few months back we installed SharePoint 2007 SP2. a Product expiration date is improperly activated. Project server expiry is for 180 days and when you install SP2, after 180 days, you will get this error message.

RESOLUTION: 
Microsoft rushed with hotfix. The good news is that customer's data, configuration, and application code is not affected. These are the steps to apply the hotfix

Step1: Download the hotfix.
Step2: Install the hotfix and choose the default settings. 
Step3: Reboot the system. 

And you are done!!. There is no need to apply the Product ID number (PID) on the Convert License Type page in Central Administration.

Cheers, 
--Aroh

Friday, November 20, 2009

SharePoint 2007 content database and its maximum size

Hi all,

The SharePoint product and technology recommends 100 GB of content database per site collection as the best practice for WSS v3 and MOSS 2007 deployments. In one of SharePoint conference Joel Oleson recommended 150 GB for a content database per site collection

Q. What happens if our content database is more than 100 GB or 150 GB?
A. Well, SharePoint 2007 and Content Database are built on SQL server & has tight cohesion with SQL tables. If content database goes beyond 150 GB, this is likely to happen:

  • SharePoint 2007 database team chose an approach where they use few tables and not using many small tables. Now, using this approach the whole SharePoint Database deisgn is prone to table-locks if content database exceeds 100-150 GB limit. Its to be noted that its NOT A LIMIT but its a recommendation.

    Moreover, SharePoint 2007 database schema has large tables (Lists, Site-Collections with huge tables) and the performance were affected by SQL Server locks. Microsoft also recommend 2000+ items for the lists

    This is commonly referred to as the “100GB content database size limitation".

    NOTE: in SharePoint 2010, 100 GB recommendation for the current database is not a problem any longer. Its due to the major architecture changes are done to the database. Please refer this article to get more information about SharePoint 2010 database changes. This time they have moved the content from single table to several tables. Hence, we can store million of items in the lists and can a huge collaborative project in just one site collection.

  • May hit the Performance SharePoint-sites.

    For an instance, we have a site-collection which contains 300 sub-sites. If the content database exceeds 150 GB or more, and users are doing some kind of insertion/update etc then that particular site collection table will be locked and subsequently other sub-sites.
If have a very large collaboration SharePoint (like 350 GB), its always to split into different site collections. Each site collection has its own content database. Therefore, in this particular case we can split 2 site collections with each site collection with its separate content database.

Microsoft has a tool for splitting site collection and move across content database: "SharePoint Administration Toolkit".

I have read some blogs where people have deployed their productions server with content database around 350 GB and growing (VSS-based backup solution in place).

NOTE:
Also, I have seen blogs where some people suggest never touch SharePoint database and they recommend to use SharePoint API (Object Model) to do any kind of updates. Its quite a valid argument but at times we need to modify the SharePoint database if a new solution or some feature get messsed up but developer MUST NOT delete any row or table if he/she does not know the usage of that table.
For an instance, look my blog, where I had developed a timer job solution and forgot to deactivate the feature, changed the scope of feature directly and upgraded the solution. My entire SharePoint environment got screwed up.
Apparently, SharePoint UI cant help . I have to modify the Database (SharePoint Configuration database ).

In fact, Sql server can go to terabyte level, but SharePoint 2007 database schema has limitations. Practically speaking, the recommendation is based primarily on two significant factors:

  1. Service Level Agreement (SLA) requirements for a given organization may dictate that backup operations for the SharePoint databases must be executable in a limited amount of time. The size of the content databases will have a direct impact on how long it takes to execute that backup.


  2. The storage subsystem must be robust enough to handle the disk I/O requirements of the SharePoint solution that it serves.


There is useful article by Joel Oleson about How large for a single SharePoint content database?

Cheers,
--aaroh

References:
1) Inspecting SharePoint Database
2) How big is SharePoint Database
3) Split large collaboration site
4) Understanding SharePoint database
5) Limitation of ECM solutions

Thursday, November 19, 2009

Wednesday, November 11, 2009

New SharePoint 2010 videos

Hi all,

A new series of SharePoint 2010 developers videos are available on Channel 9.
Here is the link.

These videos will talk about:
  • Getting started with SharePoint 2010
  • SharePoint 2010 developer road map
  • VS 2010 with SharePoint 2010 tools
  • UI enhancements
  • Lists and schema
  • Client object model
  • Workflow
  • ECM
  • Sandboxed solutions
  • SharePoint 2010 Security
Cheers
--aaroh

Low Code Reimagined with AI + Copilot Pitch Deck - Copy Copilot day (Virtual) - 2023

 Hi All,  I presneded a session at Pune UG on Low Code Reimagined with AI + Copilot Pitch Deck.  Video is at this address  https://www.youtu...