Wednesday, December 16, 2009

How to open any documents in EDIT Mode from custom ASPX page

Requirement:

We need to display documents from SharePoint Document Library into custom ASPX page and when user clicks on documents, it needs to open in “EDIT” mode, by default it’s giving user prompt to open documents in “EDIT” or “READ” only mode.

Solution:


We need to put extra JavaScript code which will open document in EDIT mode.

Reference Links:

http://ddkonline.blogspot.com/2007/07/issues-with-sharepoint-2007-checkout.html

http://www.google.com/search?q=dispex+sharepoint

http://mattknott.com/content/blog/2009/08/Stop_DispEx_Redirecting.html

http://dotnetninja.wordpress.com/2009/01/12/how-to-open-sharepoint-documents-in-edit-mode-with-internet-explorer-6-and-windows-xp-without-regfix/

ERROR: The file manifest.xml does not exist in the solution package

I was getting above error when solution package size becomes too big; I need to add below lines into cab.ddf file.

.Set CabinetFileCountThreshold=0

.Set FolderFileCountThreshold=0

.Set FolderSizeThreshold=0

.Set MaxCabinetSize=0

.Set MaxDiskFileCount=0

.Set MaxDiskSize=0

Reference Links:

http://andreasglaser.net/post/2009/03/13/SharePoint-and-the-file-manifestxml-does-not-exist-in-the-solution-package.aspx

http://ph-tom.blogspot.com/2008/04/file-manifestxml-does-not-exist-in.html

Different Method of SP List Item Update

http://karinebosch.wordpress.com/walkthroughs/event-receivers-theory/

http://hristopavlov.wordpress.com/2008/05/14/uploading-a-file-event-receivers-the-file-has-been-modified-by/

Tuesday, December 15, 2009

ERROR: Cannot override the Shared Resource Provider context obtained from the Office Server. This API can be used only when an Office Server context is either internally unavailable or defined

I was getting above error while working with BDC object model; actually I have custom code which will interact with SQL Session Provider instance and try to open SSP database.

Code

SqlSessionProvider.Instance().SetSharedResourceProviderToUse(“SSPName”);

I have found out that I need to change my custom code to work properly to remove error, I got very good reference from http://blogs.msdn.com/syedi/archive/2009/05/28/populating-the-bdc-field-of-a-splistitem-from-client-application.aspx link, which provided me BDC object model code with example.

Thank you!

ERROR: The type or namespace name 'ApplicationRegistry' does not exist in the namespace 'Microsoft.Office.Server' (are you missing an assembly reference)

I was working with BDC object model and accessing BDC application definition file from my custom ASPX page, I have included correct assembly for 'ApplicationRegistry' class but still it was giving me above error, after sometime I have realized that actually it’s looking for different assembly name to be included into page.

i.e. Microsoft.SharePoint.Portal (in microsoft.sharepoint.portal.dll).

After adding Microsoft.SharePoint.Portal assembly into page, I didn’t get any error :)

 Good Job!

SharePoint Timer Job ERROR: This job will be skipped. Failed to connect to an IPC Port: Access is denied.

I got timer job error into my virtual machine when I was running timer job by stsadm command –execadmsvcjobs

Solution:

In my case, my ‘Windows SharePoint Services Timer' service was running with normal user account, I need to changed user credentials have system account which has access to database also.

 Reference Link:

 http://ari-techno.blogspot.com/2009/08/job-failed-with-following-error-this.html

Friday, December 11, 2009

How to stop event handler recursion

I was getting errors into event log when I was trying to update list in which I have written event handler code and again that code was executed from event receiver only, so it goes in loop, sometimes my page becomes very slow.

Solution:

I need to write code which will disabled event firing before when I was trying to update something into same list and then I need to enable event firing after my code.

SAMPLE CODE:

this.DisableEventFiring();

objtem.SystemUpdate(false);

this.EnableEventFiring();

Reference Links:

 

http://www.sharepoint-tips.com/2006/10/preventing-event-handler-recursion.html

Thank you!

How to impersonate user into event receiver class or Access denied error on event receiver

Requirement:

I need to remove user permission from list item based on some specified condition; normal user don’t have rights to remove user level permission, so I need to put my business logic into RunWithElevatedPrivileges delegate into event receiver class, but I was facing some challenges after that also, normal user was getting access denied errors while breaking inheritance of list item into event receiver class.

Solution:

We need to be very careful while writing impersonation code into event receiver, because if we miss one class or object to take reference from current logged in user then code won’t work, in my case – I was taking List Item on current logged in user context, I need to be very specific for taking List Item. Key here is needs to take list item by SPListItem objItem = elevatedWeb.Lists[properties.ListId].GetItemById(properties.ListItem.ID);

 

SAMPLE CODE:

 

SPSecurity.RunWithElevatedPrivileges(delegate()

            {

                using (SPSite elevatedSite = new SPSite(properties.SiteId))

                {

                    using (SPWeb elevatedWeb = elevatedSite.OpenWeb(properties.RelativeWebUrl))

                    {

                        SPListItem objItem = elevatedWeb.Lists[properties.ListId].GetItemById(properties.ListItem.ID);

  objItem.Web.AllowUnsafeUpdates = true;

                                objItem.BreakRoleInheritance(false);

                            objLeaseItem.Web.AllowUnsafeUpdates = true;

}

                    }

                });

Reference Links:

http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/f2ccd61a-8828-4c17-8360-20d45d6b9514

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/c3d2b304-7fcc-40d2-86ce-61d9b21b03d7  

http://boris.gomiunik.net/2009/04/spsecurityrunwithelevatedprivileges-and-access-denied-error-on-event-receiver/  

Good Luck!
I had a requirement in which user can cancel / terminate workflow from custom ASPX page, I got good reference from this site http://blog.brianfarnhill.com/2008/10/01/how-to-cancel-a-workflow-programmatically/ regarding how to cancel workflow programmatically, but what I had discovered was that normal user were getting error while canceling workflow. User who has full control rights into site, they can able to cancel workflow without any errors.

ERROR:   

Value does not fall within the expected range.   at Microsoft.SharePoint.Library.SPRequestInternalClass.CancelWorkflow(String bstrUrl, String bstrListName, Guid workflowInstanceId)

Solution:

It’s because of user permission level, from out of the box workflow status page also, contributor user don’t have permission to “Terminate this workflow” functionality, so we need to put Cancel workflow logic into RunWithElevatedPrivileges delegate code. After that normal user can also cancel workflow without any errors.

SAMPLE CODE:

SPSecurity.RunWithElevatedPrivileges(delegate()

                {

                    using (SPSite site = new SPSite(SPContext.Current.Site.ID))

                    {

                        using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))

                        {

                                                            //object model code for cancelling workflow

                                   }

                    }

              });

Enjoy!

Saturday, September 12, 2009

ASP.NET Grid View

In this article, I’ll talk about and will give you reference links of simple ASP.NET grid view requirements which we are facing in day to day coding life :)

How to put radio button into ASP.NET Grid View:


http://techahead.wordpress.com/2008/04/01/aspnet-using-radio-button-inside-grid-view/


How to pass value from child window to parent window using JavaScript:



http://www.plus2net.com/javascript_tutorial/window-child3.php



How to pass data of child page grid view to parent window:



http://www.codeproject.com/KB/webforms/DataGrid_Row__Value.aspx



How to click button event on entering values into textbox and pressing enter key:



http://forums.asp.net/t/1361883.aspx



How to get readonly values from asp.net textbox to server side:



http://forums.asp.net/t/1460570.aspx



http://geekswithblogs.net/ranganh/archive/2007/05/10/112390.aspx

Object reference not set to an instance of an object. The Solution installation failed

I was getting error "Object reference not set to an instance of an object. The Solution installation failed" while adding and deploying my solution package from STSADM command, I have looked into my event log and SharePoint log to find out the exact error, I have found out that it’s related to Admin Content SQL database.  The current user who is executing the STSADM command must have full control access to this content database.

Then I run my solution package with service account and it ran well without any problem, here we can also add current user into content database and will give full control rights to current user to executing solution package.

Good Luck!

Sunday, August 23, 2009

How to Integrate AJAX into SharePoint Site


AJAX toolkit
provides whole set of controls which we can use into SharePoint, one day I thought to use AJAX Tab control, after playing with control, I realized that apart from installing AJAX toolkit into server, I need to perform set of instructions or steps to make control working into SharePoint site.

We need to make changes into web.config file for respective web application, below are some of good links which give us information about what are the sections we need to add/edit into web.config file.

Reference Links:


http://mctalex.blogspot.com/2009/06/integrating-ajax-control-toolkit-into.html


http://www.devexpert.net/blog/pt/blog/Embedding-Ajax-Control-ToolKit-into-Shar.aspx


Here is one Codeplex tool which add all web.config entries for AJAX into SharePoint site ->

http://spajaxenabler.codeplex.com/


Take the advantage of AJAX controls!!

How to assign lookup values into List definition – schema.xml file

I had requirements in which I wanted to deploy my custom lists from one server to another server, I had generated my schema and forms files using solution generator tool, now when I open one of my generated schema file in which I have lookup columns linked to another custom list, I have observed that solution generator tool commented custom lookup columns, I mean it didn’t figured out which custom list to attached for lookup columns.

There are many ways to achieve these challenges, one way would be if we know GUID of custom list which we are going to look up on then we can write same GUID into list definition schema file, but in my case all custom list was deployed at same time, so I don’t know what’s GUID of lookup list.

Another solution I found was, we can write feature event receiver on custom list, so when feature install/deploy custom list at same time we can take lookup column list name and assign into lookup columns into list definition file.

But at the last I have found simplest solution to assign lookup values into list definition, there is property called "LIST" into fields columns for schema.xml file, so in same list definition file, we can write List="Name of List" for lookup columns, so it will attached lookup list name for columns.

I hope that above information makes some sense to reader, but if it’s too confusing then please let me know about your challenges we can work out :)

Enjoy!

Sunday, July 26, 2009

Error: Invalid data has been used to update the list item. The field you are trying to update may be read only.

I was getting error “Invalid data has been used to update the list item. The field you are trying to update may be read only” when I tried to update list items with incorrect value into People and group field, I was taking value from SharePoint People picker web control and update same values into SharePoint List columns.

Actually we need to pass and assigned value into specific format to people and group data type, below link describes very good and precise information on how to get values from SharePoint people picker control and update into list columns having people data type.

http://dishashah.wordpress.com/2009/06/18/how-to-display-users-to-sharepoint-peoplepicker-and-to-get-data-from-sharepoint-peoplepicker/

Enjoy!!

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I have written web service program to fetch all list names from web application, in that case I was getting access denied error while retrieving Title of SPWEB object.

Error:


at Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException ex) at 'SPWEB.Title' threw an exception of type 'System.UnauthorizedAccessException'

I have found that my current user don’t have access rights to access some of the sites, after giving required access rights my web service program gave me correct output without any errors.

:)

Difference between Microsoft Virtual PC and Virtual Server

One day one of my friend asked me which tool are you using for SharePoint development, Is It Virtual PC or Virtual Server?

I told him, hmmm, till now I am using Microsoft Virtual PC 2007 but I thought that let me find out what is difference between Microsoft Virtual PC and Virtual Server, after doing some research I have found out that basically Virtual PC is designed for desktop PC in which Windows XP operating systems running and Virtual Server designed for server PC in which Windows Server 2003/2007 or any server operating systems running.

Another main difference I have found was, in Virtual PC we can’t connect or access one Virtual PC to another PC, but if we have Virtual Server setup into our LAN then we can connect and access all Virtual Servers.

Extensions for Virtual PC files:

Virtual machine configuration files are .VMC files,
Virtual hard disk files are .VHD files
Virtual PC saved state files are .VSV files


Reference Links:


http://blogs.technet.com/megand/pages/271852.aspx : Brief and very good difference between Virtual PC and Virtual Server

http://blogs.technet.com/keithcombs/archive/2007/06/27/vmrcplus-goes-public-download-now.aspx : Download link for VMRPlus client (VMRPlus for running virtual server)

Monday, July 20, 2009

How to open InfoPath form library into new browser window

I have found many alternatives to open InfoPath form into new window, one of them would be to take InfoPath form link URL and put same URL into summary link web part or page viewer web part.

Reference Link:

http://www.infopathdev.com/forums/p/10464/37554.aspx

Error while updating SharePoint list, “The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again”

This error "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again" is very common for beginners SharePoint developer, who start developing and digging into SharePoint object model, it’s coming while updating SharePoint list, the cause of error is due to security rights, if we make web.AllowUnsafeUpdates = true and then update the SharePoint list then we won’t get above error.

Sample Code:

Web.AllowUnsafeUpdates = true;
item["Title"]=”Sample”;
item.Update();

Happy Coding !!

Error while updating list items "Cannot complete this action. Please try again."

I was getting error while updating list items; after looking into each code line by line, I have found that error comes due to incorrect syntax near CAML query, I feel that SharePoint didn’t give us good user friendly error message to debug into our code. After making correction, my code work well.

Enjoy!!

How to give intelligence into feature XML file

One day I was creating my feature file into solution package, at that time I saw that I didn’t get intelligence of all elements and attribute into my file and I have found that by adding below schema file, we will be having intelligence in any XML file. Though it’s very small things, but I thought to share with you.

Schema file:

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML\wss.xsd"

Error while deploying solution “This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application”

I was getting error while deploying solution through STSADM command, error was This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application”

I have figured out that it’s giving me problem because of URL parameter into deploysolution STSADM command, after removing it from command, my solution package was working fine.

Reference Link:

http://snahta.blogspot.com/2008/08/this-solution-contains-no-resources.html

Wednesday, June 10, 2009

.NET 3.5 framework with SharePoint

I thought to search on how best we can get from .NET 3.5 framework into SharePoint environment, so first I have searched what .NET 3.5 framework provides us for developer, actually .NET 3.5 frameworks provides some of the good development features like LINQ, AJAX, WF (workflow foundation), WCF (workflow communication foundation) and WPF (workflow presentation foundation)

Now if we use and integrate .NET 3.5 with SharePoint then we can use same features into our development environment, but for using .NET 3.5 framework into SharePoint, we needs to install .NET 3.5 framework into SharePoint servers and has to make configuration changes like changing our existing SharePoint web application, I have also found out that there were some problem into record center site after installing .NET 3.5 framework.

Reference Links:

1. How to setup and configure .NET 3.5 with SharePoint

http://www.zimmergren.net/archive/2008/09/22/how-to-get-up-and-running-with-net-3-5-in-your-sharepoint-environment.aspx   

2. How to use LINQ into SharePoint

http://www.zimmergren.net/archive/2008/09/24/how-to-use-linq-and-the-net-3-5-framework-with-sharepoint-to-retreive-sharepoint-list-items.aspx

3. Record center SharePoint site wasn’t working after installing .NET 3.5 frameworks

http://dotneteers.net/blogs/aghy/archive/2008/10/31/moss-2007-and-net-framework-3-5-sp1.aspx

Just try it out into development machine and see how it works :)

Good Luck!!

SharePoint web services – permission for GetWebCollection method

For one of my requirement I took the advantage of SharePoint web services, actually I needs to make a windows application which will get the information for all document libraries and list down all the documents inside each document library from SharePoint site.

 

So I have used WEBS and LISTS web service to get my required results, while working with WEBS web service, I used web method GetWebCollection() from WEBS web service to take all the web site name underneath one SharePoint web site, the windows application runs well for development sites but for production sites it’s giving me unauthorized access error while accessing GetWebCollection() method, because I don’t have sufficient rights into product site, I was thinking that for executing GetWebCollection() method, I need service account or extra full control rights, but after finding from the internet, I had conclude that I just need “contributor” rights into all sites and sub-sites while working with GetWebCollection() method.

 User needs “browse directories” permission.

 Reference Link:

 http://www.novolocus.com/2008/07/03/browse-directories-and-webs-getwebcollection-strangeness/

From my point of view, we can do all things with SharePoint web services which we can achieve from SharePoint object model, just we need to know which web services and web method to call.

Happy coding !!

Anonymous access into SharePoint web services

Till now I didn’t find how to anonymous access web services, we can impersonate our SharePoint object model code by writing block of code under SPSecurity.Runwithelevatedprivileges method, I am looking for something like this for my web services code, I tried to find solution from internet, but I didn’t get success.

 

I can run or authenticate my web service code by passing current user credentials or any custom credentials (user name, password, domain name), but I am looking something different in authentication mode, please reply to me if any of you find some solutions or any alternatives for my challenge problem and I’ll also do same thing.

 

Thank you very much!

Sizes and items limitation for SharePoint List objects

Below are recommended guidelines for creating total # of site collection, webs, document library and many more …

 1. Recommended limitation for SharePoint site objects  

 http://technet.microsoft.com/en-us/library/cc287790.aspx

 2. Limitation guidelines for SharePoint 2003 and SharePoint 2007

 http://www.sperto.com.ar/fs_files/user_img/articulos/SharePoint%20Limits.pdf

 Apart from this article discussion, here is very good link which will describes logical architecture of site collection

http://www.sharepointblogs.com/llowevad/archive/2007/06/25/site-collection-logical-architecture.aspx

Friday, May 29, 2009

How to find page/site customization status – Part 2 – with the help of SharePoint object model

I know that if I find my required data/information from SharePoint database then there must be some way to find same thing from object model. So I started debugging SPFile object and tried to see what are the properties exposed by object model, but I didn’t see any properties from code, then I have found some hidden properties which match with ALLDOCS table schema, properties names are "vti_hasdefaultcontent", "vti_setuppath", so after using those hidden SPFile properties, I got my results which match with query results,

Example Code:



SPFile objFile;

string bDefaultContent = (string)objFile.Properties["vti_hasdefaultcontent"];

string strSetupPath = (string)objFile.Properties["vti_setuppath"];

if (strSetupPath == null && bDefaultContent == null)

{

//If code executed and comes into this loop then current Page/File status is customized

//then I can take objFile.File and objFile.URL values

}

Reference Links:



I have found one hidden property name from object model for checking page/site customization

http://stsadm.blogspot.com/2007/09/re-ghosting-pages.html

Hidden Property name from file object

http://www.eggheadcafe.com/conversation.aspx?messageid=29277607&threadid=29254168

Comments are always welcome!!!

How to find page/site customization status – Part 1 – with the help of Content Database Schema

Till now, that was one of my toughest assignment, my requirement was to find all pages which customized or changed from SharePoint designer, visual studio and any editor tool, when I started working on the requirements, I thought that I can easily find page customized status (ghosted/unghosted) from SharePoint object model - page CustomizedPageStatus enumeration, but that flag gave me wrong value, I mean, I can’t see my pages as customized which I created from SharePoint Designer.

 

At one time, I don’t know what to searched in Google, because I tried all combination of search query to get some useful output, but It didn’t bring me anything, all search result gave me idea and links about ghosting, how to customize page and how to reset to site definition from SharePoint designer, etc…..

 

After some time, I have found one link which says how to deal and work with SharePoint content database, so I started playing around with content database and I have found out that I can write a query which will give me page customization status, SharePoint stores all the information into database, “ALLDOCS” table has all information regarding page size, version, attached list, modified user, time and many more ….

 

By looking into schema for ALLDOCS table, I created database query and finally I got my result and I was so happy to see the result :)

 

Below is sample query which will give us all the pages which customized/created from SharePoint Designer, Visual Studio or any other editor tool.

 

QUERY:

 

SELECT

W.Title, W.FullURL,

D.DirName + '/' +  D.LeafName as pageName,

TimeLastModified as ModifiedTime,

*

FROM

Alldocs  D With (NoLock)

JOIN Webs W With (NoLock)

On W.ID=D.WebID

WHERE

D.hasstream = '1'

and D.extension  = 'aspx'

and D.iscurrentversion = '1'

and D.setuppath is NULL

 

Reference Links:

 

ALLDOCS table schema – columns and its description

http://msdn.microsoft.com/en-us/library/cc704495.aspx 

 

Database table information to find page customized status

http://sky-soft.net/SkySoft/Documentation/WSS/WSSv3Notes.htm

 

Information about SharePoint content database

http://www.sharepointu.com/ethan/archive/2007/09/16/inspecting-the-sharepoint-content-database.aspx

 

Query to find list of documents from site collection

http://stackoverflow.com/questions/213801/sharepoint-2007-sql-query-to-find-a-list-of-documents-in-site-collection

 

After finding my result from database, I thought to tried into SharePoint object model, here is link for finding page customization status from object model.

Easiest way to find file extension from SPFile Object

We can pass SPFile.Name object into FileInfo Class and get the extension of file. It will returns “.ASPX” or “.HTML” file extension depending upon file object.

 Example Code:   

SPFile objFile;

string strFileExtension = new FileInfo(objFile.Name).Extension;

Error occurred while starting of workflow (Could not load file or assembly Load Workflow Assembly System.IO.FileNotFoundException)

I was so frustrated to resolved above workflow error, because when I deployed my visual studio workflow solution package and started the workflow (manually or item created) then I was getting error in workflow status as “Failed on Start (retrying)”, also I didn’t see much useful information into workflow history, after looking into SharePoint log file, I have found below error.

Error:

Could not load file or assembly Load Workflow Assembly: System.IO.FileNotFoundException: Could not load file or assembly ‘ABC.dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxx' or one of its dependencies.
I know that there was some problem into feature.xml or workflow.xml file into solution package, but after looking into details, I have found out that I made very silly mistake into workflow.xml file, there was one tag called “CodeBesideAssembly”, we need to write only assembly name like ABC into that tag, but I wrote ABC.dll into CodeBesideAssembly tag into workflow.xml file which caused the error while starting of workflow.

After removing extra DLL word from the file, my workflow was worked fine. So be careful while making workflow.xml file.

Keep Sharing…

Sunday, May 10, 2009

SharePoint Designer (SPD) Workflow deployment

One day I have very tough requirement, my requirement was to deploy my SharePoint designer workflow from development server to TEST server, I tried to find solutions from the internet but didn’t get any easy way for my requirements, at the last I have found one very good link which fulfill my requirements, though it requires some manual steps as describes in below link.

But now I can replicate same designer workflow to target server with some or more manual changes, I know that it’s very painful at some level to do manual steps, but we can say that it’s possible to deploy SPD workflow to other machine with manual effort ….

There is no direct way to copy designer workflow from one server to another server. Only thing which we can do is through “site template” also.

We need to save our SharePoint site as template in which we have created the workflow from SharePoint designer and using that template we can create a new site on another server which will have same workflow attached with it.

Here is link which describes manual steps to deploy designer workflow.

http://www.sharepointblogs.com/andynoon/archive/2007/09/18/reparenting-a-workflow-to-a-different-list.aspx

Enjoy working!!

Wednesday, May 6, 2009

Challenges while working with object model to access recurring meeting workspace site information

I was faced many challenges while getting all agenda list, document library from recurring meeting workspace site, because when we are accessing recurring meeting workspace into object model by SPList and other object, we are only getting data of first meeting instance ID, we are not able to loop through all instance at one place.

 

Many of the people were facing same problem like me, here is one of the link http://www.eggheadcafe.com/forumarchives/Sharepointwindowsservices/Aug2005/post23625925.asp

 

I did lots of search on internet and finally I found one line of code from which I got some direction to work on. I followed this link to find my solution, http://www.eggheadcafe.com/forumarchives/Sharepointwindowsservicesdevelopment/Sep2005/post23663884.asp

 

Points to be taken care:
1. There is one hidden list called “Meeting Series” into object model, which will store all the meeting Instance ID, so we need to take each meeting Instance ID from hidden list

 

2. We need to pass meeting Instance ID to SPQuery object, SPQuery contains property to hold Meeting Instance ID.

 

Sample Code to find out all data from recurring meeting workspace site:

 

        //Check if current Web is Meeting Workspace then execute below code

        if (SPMeeting.IsMeetingWorkspaceWeb(oWeb))

        {

            //Get Meeting Series list for taking Instance ID of each workspace site

            SPList meetingSeriesList = oWeb.Lists["Meeting Series"];

 

            for (int Cnt = 0; Cnt < meetingSeriesList.Items.Count; Cnt++)

            {

                int InstanceId = Convert.ToInt32(meetingSeriesList.Items[Cnt]["InstanceID"]);

 

                if (InstanceId != 0)

                {

                    // Use SPQuery to set Meeting Instance ID

                    SPQuery MeetingQry = new SPQuery();

                    MeetingQry.IncludeMandatoryColumns = true;

                    MeetingQry.MeetingInstanceId = InstanceId;

 

                    //Do Processing of SPQuery Object and get all Agenda List, Document Library data                  

                }

            }

         }

How to get Roles and permission for SharePoint site/web

There are two powerful classes into SharePoint Object model, one is SPRoleAssignmentCollection and second one is SPRoleAssignment, we can use this classes and find permission of any SharePoint objects, starting from Site, Web, Document Libraraies, etc..

Here I am writing sample code to find all the users permission into current web.

Sample Code:

  using (SPSite site = new SPSite("http://sitename/"))

            {

                using (SPWeb objMainWeb = site.OpenWeb())

                {

 

                       SPRoleAssignmentCollection oRoleAssignments = objMainWeb.RoleAssignments;

             foreach (SPRoleAssignment oRoleAssignment in oRoleAssignments)

            {

                             // SPRoleType provide enumaration for finding all user roles like  Administrators, Designer, Contributors, Visitors

                        //check oRoleAssignment.RoleDefinitionBindings.Contains(objMainWeb.RoleDefinitions.GetByType(SPRoleType.Administrator)) value
                   //  if current role is FULL CONTROL/Administrators then it will return TRUE

                SPPrincipal oPrincipal = oRoleAssignment.Member;

                  // oPrincipal object which will return SPuser or SPGroup, depending on current object

                             }

                     }

           }

        

Reference Link:

Finding roles and permission for list
http://dotnet.org.za/zlatan/archive/2007/12/23/getting-roles-and-permissions-on-a-list-document-library-level-in-sharepoint-2007-or-wss-3-0.aspx

 

Get RoleCollection for Web Site
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.roleassignments.aspx

 

What are the changes in authorization model into WSS 3.0(introduction of new class hierarchy)
http://msdn.microsoft.com/en-us/library/ms469194.aspx

 

How to get SPUser, SPGroup, SPRole objects
http://forums.asp.net/p/1012092/3068708.aspx

Tuesday, May 5, 2009

Limitation of SharePoint Designer(SPD) Workflow

SharePoint Designer is good tool to start initial or basic level workflow, I am not expert and good person to point out any limitation into any software, but as per me below are some of the limitation which I felt for SharePoint Designer Workflow, I’ll also write you more description about some of the limitation in coming posts …

  1. We don’t have facility to send BCC email to any person from “Send an Email” actions.

  2. We can’t bind and attach more then one list into designer workflow, though there are some manual steps from where we can fulfill our requirements, but there won’t be any easy steps from interface or GUI

  3. We can’t deploy/copy our designer workflow from one server to another server like there won’t be any easy way to deploy SPD workflow from development machine to TEST and Production Server; I’ll write how to do manual steps to achieve this functionality. here is my post regarding how to deploy designer workflow ...

  4. Designer Workflow don’t give us full customized editor from where we can customized our email body text, to do this, we need to write static HTML tags into email body part.

  5. We don’t write any calculation fields or formulas into Designer Workflow actions items, like I can’t extract only date from date-time column into designer workflow interface, for this I need to take one extra column into my SharePoint list and need to manipulate into designer workflow.

  6. While working in “Send an Email” action, if we add any list column from adding “Add Lookup to Body” button and if that column don’t have any values into SharePoint list, then it’s shows as ?????? instead of blank values into email body while sending emails …


I’ll update above lists as per my experience with designer workflow.

SharePoint Designer (SPD) Workflow

I am sharing some of my good repository links regarding working with SharePoint Designer Workflow.

 Good link to start with SPD Workflow – how to send email with list columns

http://rshelton.com/archive/2007/10/05/sharepoint-document-workflow-quothow-toquot---sending-an-email-with.aspx

 How to change task list for auto generated tasks for SPD Workflow

http://www.sharepointblogs.com/tbone/archive/2008/01/10/ode-to-joy-changing-the-task-list-for-auto-generated-tasks-within-sharepoint-designer.aspx

http://nickgrattan.wordpress.com/2008/04/29/changing-the-task-list-for-sharepoint-designer-workflows/

 Applying SPD Workflow to multiple lists

http://nickgrattan.wordpress.com/2007/10/17/applying-a-sharepoint-designer-workflow-to-multiple-lists/

 Best link which will describe how to “collect data from user” action activity

http://office.microsoft.com/en-us/sharepointdesigner/HA102098081033.aspx

 Good information for how to send email with customize email message, hyperlink into with SPD Workflow

http://office.microsoft.com/en-us/sharepointdesigner/HA102390421033.aspx

How to find GUID of SharePoint list

Till now I came across many articles related to finding GUID of SharePoint list from SharePoint interface/GUI, but I think, below is easiest way to find GUID of list.

Go to respective List – >Click on Settings Menu – > Click on List Settings Link- > here in this list settings page, we can find many links, we need to click on “Audience targeting settings” link.

Now, currently we are in Audience targeting page, look up at the URL of current audience target page, that the current address have GUID of list, at the end of URL we can find GUID, like ?List={552bef05-b62c-4c76-a217-35e85a1507f1}

Thursday, March 19, 2009

Challenges and limitation while saving list as template from SharePoint GUI

I have found some limitation when I was tried to create new list from existing list template from SharePoint GUI, suppose we have 2 list and one list has lookup column associated with second list column, now we are saving or exporting both list as template and including content to migrate both list from one server to another server, when we are creating new list from saved template, at that time, we are not able to see lookup column values into first list and we are getting error “One or more field types are not installed properly. Go to the list settings page to delete these fields


 



Resolution:

I need to go into first list and again map lookup column from second list column, because while migrating list from SharePoint GUI, it didn’t keep column relationship mapping. By using 3rd party tool like AvePoint for list migration, we won’t face such type of error. We can also write custom code to migrate list from one server to another server.

Friday, March 13, 2009

Data view web part – rich HTML text problems/output caching

While working in Data View web part, I have placed user name column into my data view web part, but by default, it displayed some rich text HTML into page, in this case, we need to disable output caching for web part, so for this, we need to put disable-output-escaping="yes" tag into XSL.

 



e.g. <xsl:value-of select="@fieldname" “disable-output-escaping="yes">

 



Problem with "doctype" column name into SharePoint List

I was faced problem with column name “doctype”, I was not able to create “doctype” column with any of the data type into SharePoint List, and I was getting “Unknown error” into my page when I tried to create column. I tried to find the solution on the internet for some time, but I didn’t get good information, I believe that “doctype” column name is reserved for internal purpose, so we can’t use same name like ID, title column name.


 


Luckily I was able to create “doctype” as single line of text data type, now the actual problem started, I was not able to delete “doctype” column from SharePoint list, definitely we can write custom code and delete same column from code. But I have found easy way to delete “doctype” column from going to tool called “SharePoint Manager 2007” and I have selected my site-> list -> “doctype” column and delete from that tool. You can find more information regarding SharePoint manager 2007 from my blog, here is link http://sanketinfo.wordpress.com/2008/10/15/sharepoint-manager-2007-%e2%80%93-administration-tool/


 


Now if we have requirements to create “doctype” into list, then we can create same column name by changing character case. “doctype” column name is case-sensitive, like we can create column with named “DocType”

Tuesday, March 10, 2009

Locking down SharePoint Designer (SPD)

One day, I was getting “This web site has been configured to disallow editing with SharePoint Designer. Contact your web site administrator for more information” error while opening my SharePoint site from SharePoint Designer (SPD), after that I have found that one of my admin people change into site definition file onet.xml to restrict us from opening SharePoint designer.


 


Actually we have faced lots of problem while considering SharePoint site access, because when we were giving designer or full control rights to any users for SharePoint site, they can do customization from SharePoint Designer (SPD) tool also, but as per our requirements, only admin people can do customization from SPD, user who has designer or full control rights into SharePoint site, we would like to control them from using SPD tool.


 


I spend good amount of time for finding out the solution, but till now I didn’t find any exact and perfect solution which will best suites and fits for my requirements, because in SharePoint site, all permission are dependent on each other, so if I remove access for ‘Add and Customize Pages permission” level then “Manage Web Site” permission will be also remove from Site Permission section.


  


We can control and lock down SPD In below level.


 




  1. Site level, it’s prevent user from opening all site created from specific site definition

  2. Web Application level for all users

  3. Web Application level per users or groups

  4. Site collection level

  5. Site collection level from SPD(Contributor settings)


 


We can find many good information regarding how to lock down SPD, but guys believe me that below link giving me very good useful information and main thing, it combine and describes all possible way into one article only.


 


I’ll update my post; if I find any proper solution to locking down SPD for particular set of users with full permission access into SharePoint site from GUI.


 


Reference Link:


 


http://blogs.msdn.com/sharepointdesigner/archive/2008/11/25/locking-down-sharepoint-designer.aspx Link contains very useful information describing user security for locking down SharePoint Designer.


 


http://support.microsoft.com/kb/940958/en-us : how to change onet.xml file for disallowing users from opening SharePoint Designer

Thursday, January 29, 2009

SharePoint Auditing

SharePoint out of the box auditing features is giving us very good functionalities for keeping track of opening or downloading documents, deleting or restoring items, editing users and permissions and many more, by default its turn off on top site collection level. 

Configuring Settings for Auditing

The following screenshot shows that how we can configure audit settings from main top level site collection-> site settings-> configure audit settings. 



 
 configure-audit-settings

 

 

Viewing Reports for Auditing

 
The following screenshot shows the various auditing reports available to administrators, who can view them through top-level site settings.   

view-auditing-reports
 
When we clicked on any of the above reports, it will generate XML excel document which we can save to local disk or open for viewing purpose. 

 



Limitation for audit reports:

1. the generated XML excel document report don’t have user friendly data, like in “Event Data” column, it will display user id, group id instead of friendly user name and group name, it showing site collection GUID instead of Site Collection name and many more.

2. For viewing of auditing reports, user needs site collection administrator’s rights and user can see reports from going to top level site collection. 


 



3. If we have large server farm with plenty of SharePoint sites under one site collection level, then at some point, we can have performance issue due to tracking all users’ requests for audit purpose. 

We can write custom code into visual studio and generate audit log reports as per our requirements.


I have also searched on the internet for tool and web part to display and capture audit trail reports from SharePoint.

Here is link for useful AvePoint tool for SharePoint auditing

http://www.sharepointreviews.com/component/content/article/69-sharepoint-auditing/210-DocAve-Auditor-for-SharePoint-by-AvePoint.html 

Below are some good useful links which talks about how to configure auditing, viewing reports and how to write custom code for generating user friendly reports.
 

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spauditentry.aspx SPAuditEntry Class which will use for writing custom event data into audit report.

http://msdn.microsoft.com/en-us/library/bb397403.aspx Item Level Auditing in SharePoint 


http://www.developer.com/net/net/article.php/3755726  Source code for custom audit log reports 
 


 

http://office.microsoft.com/en-us/sharepointserver/HA101000051033.aspx how to view audit log reports

http://msdn.microsoft.com/en-us/magazine/cc794261.aspx custom auditing 

Monday, January 26, 2009

Working with SharePoint meeting workspace site

From last 3 weeks, I have been working in SharePoint meeting workspace site, so thought to share with you some of the experience and what’s actual inside into meeting workspace site.


 Our main purpose was to create calendar event into SharePoint and store meetings documents and agenda for respective meeting into central location repository, so anybody can go into meeting workspace with proper permissions rights and browse through the documents uploaded and approved by meeting organizer, meeting workspace is working in same manner like outlook calendar, we can create recurring event, single day event and add attendees, agenda for the meeting and upload documents.


In traditional outlook meeting, organizer has to send documents, agenda to attendees by e-mail, so they were no central repository for all work items and documents.


 


We had met our requirements by out of the box functionality provided by SharePoint Meeting workspace site template. We can also do custom coding into meeting workspace as per our needs.


 


Below are some useful links which I had followed while starting working on meeting workspace. It’s very beginner’s level information.


 


http://office.microsoft.com/en-us/outlook/HP030921661033.aspx Overview about meeting workspace site


 


http://office.microsoft.com/en-us/sharepointtechnology/HA100656201033.aspx Creating meeting workspace site


 


http://community.bamboosolutions.com/blogs/sharepoint_blank/archive/2008/10/31/create-a-sharepoint-meeting-workspace.aspx How to create and start with meeting workspace site


 


http://office.microsoft.com/en-us/outlook/HA012304711033.aspx#2 Create, Link and Update meeting workspace site.


 


http://communityclips.officelabs.com/video.aspx?videoid=601655a8-2111-4406-821d-690f2fce6b35 creates recurring meeting workspace and connects to Outlook


 




I had also faced some of the challenges while working into meeting workspace

1. we can’t link to an existing meeting workspace that contains recurring events, like when we create any new calendar event into SharePoint, we can specify that current event will be recurring or not, after that we can create new meeting workspace subsite for storing all documents, agenda items and attendees, we have the option to link current site with existing meeting workspace site in which there was no recurring event, but we cant link to existing recurring meeting workspace site. So conclusion of the story, we need to create separate meeting recurring workspace site if we want our recurring dates and agenda different from existing one.

 


2. Meeting workspace site has some limitation with office 2003, we can also create new meeting workspace site from outlook calendar by creating new calendar event, select invites, here we have two options, either we can link to existing meeting workspace or create new workspace site, but in both the case, the meeting organizer needs to have full control to the Meeting Workspace from SharePoint site, with the full control rights, they can achieve the functionality from outlook 2003.