Monday, October 10, 2011

Something in SharePoint (2007 & 2010)

There is a funny thing in SharePoint (in all versions)

1) List

With normal list the URL like http://server_name/site_name/Lists/List_Name
With documents list the URL like http://server_name/site_name/List_Name

2) Site

With normal site, all lists have the full controls on the list such as deleting, saving template,...
With blog site, the Posts list does not have permission to delete or save as the template and after save the blog site as template, we cannot restore the site correctly. All views of Posts list are generated as a list with the same name.

Friday, September 30, 2011

How to get all subsites if logged by Reader or Contributor

Sometime, we need to go through all sub-site of site collection to do something, however, it's very easy if you are logged in by Designer or Full Control. Because these account have full rights on subsites and the problem happens with Contributor or Reader. Look at the code:


SPWeb parent = SPContext.Current.Web;
foreach (SPWeb web in parent.Webs)
{
          try
          {
                    table.Merge(this.GetDataFromURL(new Uri(web.Url), schemaName, itemLimit));
           }
          catch (Exception ex)
         {
                //logger.Warn("DataBind::", ex);
         }
         finally
        {
              web.Dispose();
       }
}

The code runs without error but you will get the Access denied on the page and the stack trace shows full message like: "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." That's very bad practice. Because of requirement, there are some subsites that Contributors or Readers do not have permission to read. However, we must get the data from remaining subsites which they have the right to read the data.

The code will change to:


SPWeb parent = SPContext.Current.Web;
parent.Site.CatchAccessDeniedException = false;
foreach (SPWeb web in parent.Webs)
{
          try
          {
                    table.Merge(this.GetDataFromURL(new Uri(web.Url), schemaName, itemLimit));
           }
          catch (Exception ex)
         {
                //logger.Warn("DataBind::", ex);
         }
         finally
        {
              web.Dispose();
       }
}


We need to set property "CatchAccessDeniedException = false" for SPSite object. SharePoint will know that catch any site does have permission to read. As a result, you never get "Access denied" exception on page but you also never get data correctly, because the collection of Webs will throw exception if any subsite strict from user does not have permission.

The best practice for this issue is to get all subsites which Current user has the right to read, the code to change again:


SPWeb parent = SPContext.Current.Web;
parent.Site.CatchAccessDeniedException = false;
foreach (SPWeb web in parent.GetSubwebsForCurrentUser())
{
          try
          {
                    table.Merge(this.GetDataFromURL(new Uri(web.Url), schemaName, itemLimit));
           }
          catch (Exception ex)
         {
                //logger.Warn("DataBind::", ex);
         }
         finally
        {
              web.Dispose();
       }
}


Method "GetSubwebsForCurrentUser()" of  SPWeb just gets all subsites which current user is to be able to access, atleast, reading the data.

Monday, August 29, 2011

Error Posts List when create a blog site from blog site template!

Haizzzzzzz...., I was so happy when I was working on SharePoint, especially is SharePoint 2010. But! Still But and But...SharePoint 2010 seems to be stopped if we could not find out the error and these issues are a WAD or not...nobody knows. And the HOTFIX is the best choice to solve the problem.

This time, I show you guys a simple issue but it was not fixed in June 2011 hotfix.

Step 1) Create a blog site. Design by yours, Customize by yours...Look nice.

Step 2) Save as a template to be used for the second time or another server...

Step 3) Import this template and create a new blog site base on this template.

ahahaha...:D Issue........

Open the newsite, then go to Site Action and View All Site contents. You will see:


And...what's happen then? You can work on new site as normal, but you cannot save the site template from new site, sharepoint will give you an error because many links blog are the same but actually it's the only one.

I am using foundation with the simplest configuration.

Any body helps me? /Thankssssss

Friday, July 22, 2011

Resolved: using [Today] in formula of Calculated column.

Situation:
I have a check list is listing the domain name of customers who registered the domain with my services. I need to know the remaining of the validation date and send to customer an email. The expiration day is calculated from due date until today.

Problem:
I created a list with Due Date column with DateTime formated. Another column called remain days belongs to calculated with the formula like this: [Due Date] - [Today]. After click save, I got an error:


That means, I can not use the SP variables, but I can define a custom column with the formula had an existed SP variable such as [Today] and [Me]. And I have another solutions:

1) Create a new column named Today with type of DateTime
2) Modify the Remains column if you had created before. Change the formula to [Due Date] - [Today] with [Today] is a new column.
3) Delete [Today] column.

As a result, the Remains column is calculated from Due Date to today.

Sunday, July 17, 2011

How to connect to MICROSOFT##SSEE (Windows Internal Database) - SharePoint 2010

In a previous post, I introduced the way how to connect to internal sharepoint database. But the limited is just supported for SharePoint 2010.

In SharePoint 2010, something changed in the structure of Database such as the instance name is SERVER\SHAREPOINT instead of SERVER\SQLEXPRESS or SERVER\OFFICESERVERS,... or something like that.

And it's easy to understand that internal database also gives the way easiest to connect to database, just replace the instance name in connnection string to "SHAREPOINT": \\.\pipe\MSSQL$SHAREPOINT\sql\query

Sunday, July 3, 2011

Installing and Configuring Bamboo Discussion Board Plus for SharePoint

In forum view, there are two parts: Sticky topics and normal topics. Some important topics need to be shown at the top of the Discussion Board. By selecting the topics as sticky they will be displayed at the top under Sticky Topics. Other topics will be shown under the Topics section. All topics are sorted by the Last Posted time. In addition, each of the sticky topics is marked as sticky with a sticky icon () to the left of the title.


Read more at: http://community.bamboosolutions.com/blogs/bambooteamblog/archive/2011/07/01/installing-and-configuring-bamboo-discussion-board-plus-for-sharepoint.aspx

Saturday, June 25, 2011

Why Microsoft recommended that should not use Microsoft.Web.CommandUI.dll in any SharePoint products??

Almost asp controls of SharePoint has imported the namespace "Microsoft.web.commandui.dll" to manage the Ribbon. However, this dll wasn't recommended to use if you need to customize your Ribbon. To use the type or namespace of Ribbon, we should use "Microsoft.SharePoint.WebControls". Or course, in Microsoft.SharePoint.WebControls namespace also has implemented SPRibbon, but it's not enough.

Deassembly the WebControls namespace, SPRibbon only has some types, especially it does not have TrimById method, just Microsoft.Web.CommandUI.dll has.

I don't understand why Microsoft recommended that should not use this dll!??

Do not use types or members of the Microsoft.Web.CommandUI namespace for development within a SharePoint environment, but instead use SPRibbon and related types in theMicrosoft.SharePoint.WebControls namespace. For information about customizing the ribbon in SharePoint Foundation see Server Ribbon in SharePoint Foundation.

Anybody helps me?

Friday, June 24, 2011

Passed the examination 70-573: Microsoft SharePoint 2010, Application Development

I've decided to attend the examination 70-573 because I am working as Developer of SharePoint 2010.
It's not difficult for me because I had attended the Online Course:

and now it helps me a lot in my work, i feel better after finished learning the course and passed the examination. I will return to my blog in short day and continue sharing my knowledge about SharePoint 2007/2010.

Thanks for my co-worker helping.

Tuesday, June 21, 2011

Passed the examination 70-576: Designing and Developing Microsoft SharePoint 2010 Applications

I'm very happy to notice that I just passed the examination of 70-576.

A lot of skills need to be improved if you learn onlin at:

http://www.microsoft.com/learning/en/us/exam.aspx?id=70-576

Of course, that's very good document and orient the right way to pass the examination. After finish the online course you will learn the strongly knowledge to work with SharePoint 2010 with Design and Develop software based on SharePoint 2010.

Thanks again.

Thursday, May 12, 2011

What about the issue of Calendar in SharePoint 2007 show wrong datetime.

I decided to post this issue because I did not find out any wrong in my system, and if it is a WAD or Bug, please confirm this topic is correct and I will send this link to my customer.

Problem:

Install SharePoint 2007 with the default settings for everything. Create a celendar list and then create a column named "My Date Time" or something you want with DateTime type and show both Date and Time.

Create an item in Calendar with All Day Event checked, type a date into "My Date Time"

After save, everything is fine. Please see the picture in view form.

Title, AlldayEvent, My Test Datetime show correctly, data kept. But what is happening when I edit this item?


"My Test Datetime" was wrong, the date is minus 1 day and if I save this item, the data will store this date.

There is very strange that it will not change for the next editing. And this issue does not happen in SharePoint 2010