Monday, December 23, 2013

SharePoint Updates, Cummulative Updates and Patches: December 2013

Before to end of 2013, Microsoft has released an update for SharePoint including both Foundation and SharePoint Server.

This update fixed some issues not important and the important issue is not fixed. Performance Point is a very helpful service in SharePoint and it is very important in SharePoint 2013 environment. However, this released has been fixed many issues from another update and resolve a lot of bugs before.

To download update for SharePoint Server 2013, click here

To download update for SharePoint Foundation 2013, click here

SharePoint Designer 2013, click here

Office Web Apps, click here

To download update for SharePoint Server 2010, click here

To download update for SharePoint Foundation 2010, click here

Sunday, November 10, 2013

Add a New Language Pack to Community Central in SharePoint 2013 and 2010

The latest release of Bamboo's Community Central offers a host of new features and customization options. One of the new features included are site templates for different languages including German, Russian, and Arabic. In the event that you need to have even more languages, have no fear, for this post is here to help! In this article, we'll show you how to build a new language for Community Central.
Some items worth noting before you begin:

  • In this article, we have chosen to add a language in SharePoint 2013 using the SharePoint 2013 language pack. Please note that if you are using SharePoint 2010, all steps are exactly the same.
  • Bamboo Community Central has 3 templates: Community Central Home, Blog Home, and Forum Home template. In this post, we will be adding the language to a site that utilizes the Community Central Home template. 
Details of article is here:

http://community.bamboosolutions.com/blogs/sharepoint-2013/archive/2013/11/08/add-a-new-language-pack-to-community-central-in-sharepoint-2013-and-2010.aspx

Tuesday, August 20, 2013

Fixed: Error CS0030: Cannot convert type DelegateControl to IAttributeAccessor

Sometime, we get the error "error CS0030: Cannot convert type 'Microsoft.SharePoint.WebControls.DelegateControl' to 'System.Web.UI.IAttributeAccessor'" when we customize the masterpage of SharePoint. Many people think that the error comes from mis-typed or SharePoint does not recognize the control with tag name <tag:Delegate> and the solution is to remove that line. Of course, it will work correctly and you could see there is no error after that.

With my solution, there is no need to delete or remove the delegate control out of master page. The error happens because the structure of HTML for delegate control is not correct and you need to review the code to make sure that the hierarchy of HTML page is right. Sometime, there are many break-lines (the empty lines or too much enter key pressed...) also to get this error.

Case Sensitive in SharePoint

I actually didn't know about some areas in SharePoint using declaration with case-sensitive until today I work on List Definition and Custom Activity.

1) When we define a new list, we must define the list of fields and their properties. Especially in the schema for field, take a look the definition schema field by MSDN:

<Field
  ID = "Text"  Id = "Text"
  Type = "Data_Type"
  ...>
</Field>


Where:
ID: is the GUID of the field and put it into {...}
Id: is the text optional

The confusing thing is if you define the field with type is different from Lookup, you might use Id instead of ID. But if you declare the type is Lookup, you must use ID unless the feature couldn't be activated. Althought Id is the optional text but you are still able to use as ID.

2) If you code a custom activity and need it to be availabe on SharePoint Designer while you are designing a workflow, you must define the mapping type in WSS.ACTION file (you can find here C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\1033\Workflow)

The most important thing is all declarations in this file are case-sensitive and you must correct it before to use. It took me some hours to find out the error because I defined ID instead of Id in the field binding

        <FieldBind Field="Error" Text="this message" Id="1" DesignerType="TextBox"/>


That's awesome!

Thursday, July 18, 2013

SharePoint 2013 updated / July 09, 2013

The hotfix July 09, 2013 has been released to update Edit Links button in the main navigation menu on SharePoint Server 2013 sites is incorrect.

To download the update, click here: http://support.microsoft.com/kb/2817321
Please read carefully the document before doing updated.

Thursday, February 28, 2013

MSOCAF rule: SharePointFeatureReceiver must log to ULS Logs.

If you are working on Apps or Web Part for SharePoint Online (Office 365), you must run the MSOCAF to check all rules accepted by Microsoft before deploy on SharePoint Online. One of these rules there is a rule for Feature Receiver. The code which is implemented for Feature Receiver will fire when the feature is activated, de-activated, activating or de-activating. And if there is any error during the executing time, all exceptions must be log so that user can handle the exception.

This is example:

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            try
            {
                //TODO: SOMETHING
            }
            catch (Exception e)
            {
                logger.Write("Error:", e);
            }
        }

To handle exception, I write the value of "e" variable to log file in TMP folder. Ans result as well if the code run under SharePoint local or SharePoint hosting. But it is not compatible with SharePoint Online, and because Office 365/SharePoint Online will write the log into SharePoint list and MSOCAF will not accept this way to manage the error.

 MSOCAF will give the message:

  The catch block at line number '[symbols not found to locate the line number]' in method ...FeatureDeactivating(Microsoft.SharePoint.SPFeatureReceiverProperties) must log to ULS Logs. For ULS logging, please use the Microsoft.SharePoint.Administration.SPDiagnosticsServiceBase.WriteTrace API in SharePoint 2010.

To solve this issue, just throw exception to parent process and write the exception to SharePoint log.

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            try
            {
                //TODO: SOMETHING
            }
            catch (Exception e)
            {
                Microsoft.SharePoint.Administration.SPDiagnosticsServiceBase w = SPDiagnosticsService.Local;
                w.WriteTrace(1, SPDiagnosticsService.Local.Areas["SharePoint Foundation"].Categories["Unknown"], TraceSeverity.Verbose, "");

                throw new ApplicationException("Feature1EventReceiver.FeatureDeactivating", e.InnerException);
            }
        }
You can customize the log category and severity to show the exception to be friendly instead of leaving the default setting.

Wednesday, February 27, 2013

Best Practice coding & MSOCAF checking for SharePoint 2013

Sometime, I think that to convert the code of web part from SharePoint 2010 to SharePoint 2013 is simple to change the reference all of SharePoint DLLs then make a package. That’s it. But it is not simple as I thought. The Apps or Web Parts which are running on SharePoint 2013 must be also checked by MSOCAF before they are pushed on storefront. MSOCAF will check many rules to improve the performance, guarantee the safety security, memory leaks and other things following the test cases. The specialist is to have the difference between MSOCAF for SharePoint 2010 and MSOCAF for SharePoint 2013. Except for 2013 upgrading rules and some new rules, the code for 2010 could not apply to 2013.

Here is example: To improve the performance in process the large list, my code in SharePoint 2010 look like this:





 Of course, that code was passed by MSOCAF for SharePoint 2010. But it’s failed by MSOCAF for SharePoint 2013.
 




 The message shows that the object “SPListItemCollection” must not be declared in the loop statement. Assume that if you need to process data through SPListItemCollection object, so you must declare an “items” variable to handle the collection of items after execute the query. By this way, you will interact to SPListItem object easily, but unfortunately the MSOCAF catches the code in violation of rules. Now, I try to write another code of using SPListItemCollection in the loop statement to make sure this rule is very confused.



And as a result:



That’s for sure SPListItemCollection must not be declared in loop statement, instead of using another C# object to handle a collection of SPListItem. My solution is to change the code using DataTable instead of SPListItemCollection and process the data through that array.




And result is:
 


Conclusion:

 Try to use the .NET object collection in loop statement to improve your performance, or if you need to use SPListItemCollection object, try to build the query CAML with many conditions and execute one time to avoid the loop and pass the MSOCAF checking. For now, I don’t have any solution as well to pass the MSOCAF checking with this rule, I just try to change the code a little bit and use .NET object collection for my purpose. In many cases, think more about the situation to avoid using SharePoint object modal , and of course by using .NET object collection it will improve performance a lot while SharePoint object modal collection still keeps the connection to database when we access to each of item in collection. I think that’s the reason why SharePoint 2013 does not recommend to use SPListItemCollection in loop statement.

Tuesday, January 1, 2013

Insert smileys and Thanks button for SharePoint Discussion List


Some days ago, after I worked on my forum (sharepointvietnam.net) I found the Mod that is very useful. It called Thank Mod. If you read a topic or reply a post and it helped you somehow to solve a problem, you will say “Thank you” and on community or forum you may click on Thank button an you only can say thank for one time on the post.
SharePoint Discussion List has the functioning similar to forum of vBulletin or phpforum. However, SharePoint Discussion List just limited the functioning on creating the topic and other users can reply on the topic. To expand or plug into this list much more features it’s not easy and if you need it to be have fully features like others forum, let build a project then add the existed featured from my topic and from others on the internet. In my topic, just there are 2 small features: insert smileys and thank button, just ask Mr/Mss Google to get more functionalities.
Two features in this topic are here:

Please read carefully my topic before deploy or install:
  • Backup these files in HIVE\14\Templates\Layouts\XSL: main.xsl, thread.xsl, vwstyles.xsl and internal.xsl because these files will be replaced the original after installed. If this feature or solution is removed then these files will also be removed out of the folder. Now, just restore them from a backup folder.
  • After install/deploy, run the command iisreset and create the new discussion list to get the effected.
To insert smiley:
Click on the editor area then the contextual ribbon would appear and click on Insert tab


Click on Smileys button, the popup will show on top:

Click on the icons to pick-up one or more icons which would be inserted into the topic.
There is a thing you should pay attention for the upgrading in future: you could see 4 tabs on the popup window, that is because there are 4 emotion folders in Emotion Project folder. You could find them in HIVE\14\Features\EmotionProject

For now, think about how to install or remove one or more emotion categories and the answer is so easy, just create a folder as category and copy all emotion files to the folder. Then, re-open the popup window smileys it would be updated immediately.
Notice: do not click on the checkbox, just click on the icon, the checkbox will be changed the status automatically.
In addition, you can say thank to the owner of topic by click on Thanks button:

If you have never click on Thanks button for the post, you will see Thanks button and other people say thank to the owner of the post. Ater click Thanks button, your friendly display name will appear under the line and you could not say Thanks again for that post, and you also could not remove your thanks in the thanks list, so let pay more attention or think much more about the post to say Thanks or not. It may have a difference thought from Facebook like button, you can remove (unlike) a status if you have a difference mind.
Thanks button will only appear on both Flat view and Thread view. If you need the thanks button appear on your customize view, please add the code to your xsl file render:

In the project, I used the jQuery library and if there is any conflict with your product, please remove my jQuery library and used yours, that’s not important and work as well.
Good luck to you.