Showing posts with label SharePoint 2013. Show all posts
Showing posts with label SharePoint 2013. Show all posts

Wednesday, April 1, 2015

Explain the abbreviation in SharePoint

Regarding to request from my friends having the explanation of abbreviation in SharePoint. This may not totally enough but it might help you know clearly when you read the document.


  • WAD: work as design. You were surprised of strange thing when you do something on SharePoint list or page. You think different and the result must be like your thought. E.g: When you switch from Subject view of discussion list in SharePoint 2013 to Management view, you think that the page will redirect to flat or thread view. But the result was not shown the same as your though. It redirects to itself and you see the item was clicked to be a folder. It calls SharePoint WAD.
  • OOTB: out-of-the-box. This term lets you know what SharePoint support. E.g: In the discussion list of SharePoint 2013, it was integrated the Like and Rating for SP Office Server version. You needn't install any 3rd-party to support the rating and like functioning for this list. This function is called SharePoint OOTB. Almost SharePoint software company produce a product or customize or give a solution are having the idea to support the functioning that SP OOTB does not have.
  • CSOM: client side ojbect model. This abbreviation is related to the program is run on client side. E.g: You want to create a console or windows form to access to SharePoint site and SharePoint server is working as remoting. You can use C# or VB to develop the program and, of course, SharePoint always support the DLL for your reference to the code.
  • JSOM: javascript object model. This model works only in the SharePoint application page or web part, or whatever you need to run in the web page.The objects is built in the SharePoint's JS files in the layouts folder of 15/hive (14/hive). E.g: You build a web part and you need to access the list at the run-time, you could implement something like this:
          var web = SP.ClientContext.get_current().get_web();
  •  REST API: Representational State Transfer API. Think of it simple like coding by javascript, vb or c#. Actually you have to use javascript object to access the SharePoint items. A technical named RESTful will help you understand a deep knowledge base of this term. However, you can image that you can access to all SharePoint objects site by using an address and the method of client context. REST API just only support on SharePoint 2013 and SharePoint online (Office 365). For more information, click  on REST API reference and samples. For SharePoint 2010, you could get and install MashPoint REST by Bamboo Solutions. REST API helps you access the site anywhere, easy to learn, safe in work and fast on time.
         For more information of REST vs CSOM, visit AndrewConnel blog
  • Built-in: This term means you don't need to customize anymore. Just get and build. E.g: You need to build a custom column with a compatibility functioning in the backend, but it's so simple in the new/edit/display form because you only use the controls that SharePoint has been supported. That calls built-in controls.
  •  More...
Hey guys, please let me know more abbreviation!

Monday, March 30, 2015

List Definition was changed the schema for existing lists!

Until now, I did not know exactly the processing of deployment list definition and there is any changes on each of SharePoint version. I have scenario that I am facing the problem with migration and upgrading list definition. Just is:

I create a list definition based on custom list, because I need to declare all fields, views and the user interface rendering. It's actually basically and for testing purpose only.

The list has only one column named "Title" as default, because I do not know what the next column is to do, so I will upgrade the list def later. I called the list /w version 1.


I modified the list definition schema to add more fields:


Then, from Visual Studio (version 2012) context menu, I click to deploy directly to site. Of course yes if I create a new list base on my list definition having new schema with new 2 columns. But I get the warning that the list definition is created before deployment will be delete the schema and effect to new schema from Visual Studio:


That means all my existing lists will be effected to new schema and they work correctly. The result looks like this:


The question is if I don't use Visual Studio to deploy directly to my server in many scenarios, what happen on my existing lists? for example: some of deployment tools just do copy a schema to physically installation folder and then do reset the IIS or even executed the stsadm command to deploy from wsp. I have tried to do some tests by copy/paste the new schema to feature folder and then execute iisreset command (and deploy by executing stsadm command to deploy wsp). As a result I can still see my 2 new fields in the list settings, however, they did not work correctly. Basically, to access the value of SPListItem, it will throw an exception "Object is not set reference...". It's right because it does not have the default value and it's added after item was created.

The most important thing is if we don't use Visual Studio to upgrade the lisf definition, what do we need to do upgrading the existing lists?

Solutions: After deployment process finish, the all existing lists are effected with the new schema, thus, to determinate the old lists must be based on the other information of the list with specific scenario. For example: properties bag of list/field does not change after deployed the new updates, or checking the dependency to update the old list.

  • fields: add/remove/update by code
  • data: using Batch update command to avoid the performance issue.

SHOULD NOT DO: 
  • Do not delete the field and then add the new field if the old field and new field has the same as schema.
  • Move data from old field to new field because it will happen performance issue. In the feature activating/upgrading process, there is not enough time to upgrade the data for large list. 











Wednesday, February 11, 2015

Stuck in stupid with the error "Object does not support this method..."

Sometime I got the stuck in coding and it seems taking waste time to google or ask for help in forum. Eventually I found the stupid reason that I don't think about the basically knowledge.

Look at the code:


var clientContext = SP.ClientContext.get_current();
var list = clientContext.get_web().get_lists().getByTitle(context.ListTitle);
                
I got the error "Object does not support this method..." bla bla bla. Now, I know you will ask me in your mind the question is where the code is put in! For being time, I cannot answer your question unless I could resolve the problem.

After doing a forage in the internet, I remember the terrible reality suddenly. I forgot initializing the object SP.ClientContext in the sp.js! Wow hooooo....That code was changed:



SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {
        var clientContext = SP.ClientContext.get_current();
        var list = clientContext.get_web().get_lists().getByTitle(context.ListTitle);
               .....
});
                

Done!
Everything is resolved!

Wednesday, January 14, 2015

Resolved: Save conflict!

I've got the headache for one week when I tried to add a new column into list by ListAdded event receiver. It was through the exception "Save conflict..." and I've tried many ways to fix this issue, but I failed.

{
   list.AddFieldAsXML("field_definition");
   list.Update();
 
   //Resolve here - re-fetch
   list = web.List["ListID"];
   SPField newF = ...
   newF.Title = "New Title";
   newF.Update();
}

I really stuck in the dark hole!

Resolve: Sometime, you should refresh your life by hanging out with your friend or buy a ticket for comedy show. For what? To clean all the troubles, problems and worries about the life. I've never thought about the FETCH until now that the list defninition in the database was changed. To update anything into list, just re-fetch the list! That's all. God save me life!

Gravo!

Sunday, November 9, 2014

[How To?] Set expiration policy for items

Sometime, we've got the stresses to see a warning message from system event viewer. It showed the database limited exceeded or the list is reached the threshold for auditors and administrators but it's not too many items in the list. If you don't want to waste the resources, databases and the time to access the list, there is a way to delete the very old items and think about the deleting process in case.

Microsoft Office SharePoint Server [2010, 2013] has a feature to cover all items following the date and do an action if the condition in criteria reaches out.

Here is a instruction to set the expiration for SharePoint list item

  • Go to Central Administration -> Monitoring -> Review Job Definitions: to make sure that the job named "Expiration Policy" is running.

  • Go to Site Actions -> Site Setting -> Site Content Types under Galleries category. Click on any content type that you want to set the expiration date. This is not applied to specific list/site or item but for content type. 



  • Click on Information management policy settings to enable the Retention option.



  • The Library Document has own the retention settings, if administrator defines the stage in library setting, the setting for document content type will be overwritten. If there are many stages in the setting, make sure that the action and condition in each stage is separately and unique.   
  • In this challenge, I will define a stage to delete very old item. See a picture
  • All items there were created a month ago will be deleted automatically.
  • Of course, we could define many stages for one content type and each of stage can have a repeater actions.
Limitation:
  • It's only available for Microsoft Office SharePoint Server. There is no feature for SharePoint Foundation.
  • We could not define a condition with specific date.
  • It has not supported the query condition instead of selecting on date-time column.
  • There is no exception on the query.
  • There is no configuration for specific list, site or item.

Friday, July 25, 2014

Access denied while the code accessed the property named MyWeb.Navigation.UseShared in SharePoint 2013

I don't know the reason why it took a long time for me to fix the issue in SharePoint 2013. I don't know whether my SharePoint developing skill is down or not and I think I am too old to work as a developer.

My situation is:
Step 1: Backup database of web application in SharePoint 2010
Step 2: Attach this database into SharePoint 2013
Step 3: Upgrade the site

Result:
Everything worked correctly accept for the home page throw the error "Access denied". They show "this page is not shared with you!"

The home is inherited the custom master page and using the custom code to add the navigation to top link bar.

This is a code:

            MyWeb.AllowUnsafeUpdates = true;

            if (!MyWeb.IsRootWeb)
            {
                MyWeb.Navigation.UseShared = true;

                if (!MyWeb.ParentWeb.Navigation.UseShared)
                {
                    // Get top link bar.
                    SPNavigationNodeCollection topnav = MyWeb.ParentWeb.Navigation.TopNavigationBar;

                    serverRelativeUrl = MyWeb.ServerRelativeUrl;

                    // Query for an existing link.
                    SPNavigationNode node = topnav
                        .Cast<SPNavigationNode>()
                        .FirstOrDefault(n => n.Url.Equals(serverRelativeUrl));

                    // No link, so add one.
                    if (node == null)
                    {
                        // Truncate long a title.
                        string linkTitle = MyWeb.Title;
                        if (linkTitle.Length > 15)
                            linkTitle = linkTitle.Substring(0, 12) + "...";

                        // Create the node.
                        node = new SPNavigationNode(linkTitle, serverRelativeUrl);

                        // Add it.
                        node = topnav.AddAsLast(node);
                    }
                }
            }

            MyWeb.AllowUnsafeUpdates = false;

You know what,  the property named "MyWeb.Navigation.UseShared" is only work with Design role assignment or higher. If I logged into site by contributor, it will throw exception "Access denied".

This is error tracking:

System.Threading.ThreadAbortException: Thread was being aborted.   at System.Threading.Thread.AbortInternal()   at System.Threading.Thread.Abort(Object stateInfo)   at System.Web.HttpResponse.AbortCurrentThread()   at Microsoft.SharePoint.Utilities.SPUtility.Redirect(String url, SPRedirectFlags flags, HttpContext context, String queryString)   at Microsoft.SharePoint.Utilities.SPUtility.RedirectToAccessDeniedPage(HttpContext context)   at Microsoft.SharePoint.Utilities.SPUtility.HandleAccessDenied(HttpContext context)   at Microsoft.SharePoint.Utilities.SPUtility.HandleAccessDenied(Exception ex)   at Microsoft.SharePoint.SPSecurableObject.CheckPermissions(SPBasePermissions permissionMask)   at Microsoft.SharePoint.SPSecurity.ValidateSecurityOnOperation(SPOperationCode code, SPSecurableObject obj)   at Microsoft.SharePoint.SPSecurityOnOperationScope..ctor(SPOperationCode code, SPSecurableObject obj)   at Microsoft.SharePoint.Navigation.SPNavigation.set_UseShared(Boolean value)   at Bamboo.CommunityCentral.MasterPageBase.<AddCentralSiteToTopLinkBar>b__5()   at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.<RunWithElevatedPrivileges>b__3()   at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)   at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)   at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)   at Bamboo.CommunityCentral.MasterPageBase.AddCentralSiteToTopLinkBar()   at Bamboo.CommunityCentral.MasterPageBase.OnLoad(EventArgs e)

Remember: That code cannot work under privileged delegation, thus there is one way to pass the error is to check the current user before apply the code.

Good luck to you.

Monday, July 14, 2014

[Resolved] Error: Unable to get value of the property 'showWaitScreenWithNoClose': object is null or undefined

Today, I will try to use the API with a wide library JS in SharePoint 2013. If you are familiar to JS and SharePoint Client Object Model, you will know how to call a method or execute a query using SharePoint API. However, to work with SharePoint 2013 smoothly, you must research what the SharePoint did!

In some js library, SharePoint had supported a debug file to help you learn to be acquainted with approaching API client library. And I have resolved a great of issues based on that.

My use case is: when I click on a post-back button, after the back-end processed and return the data, the page is reload and I don't want to submit as a post-back re-rendering all view state. The code looks like:

<asp:Button runat="server" Text="Process..." OnClientClick="Update()" OnClick="btn_ProcessClick"></asp:Button>

and the Js code is:

function Update() {
        var dialog = SP.UI.ModalDialog.showWaitScreenWithNoClose("Waiting!", "Processing...");
}

I did not implement any remaining functions, just need to test a window dialog to ensure the dialog works fine. But the result is:

Error: Unable to get value of the property 'showWaitScreenWithNoClose': object is null or undefined



My though is all client scripts are loaded and SharePoint did by using the default master page. And that's true! However, to initialize the object or class we must ensure the script loaded into page before using. To fix this issue, the code was changed:

var fn = function() {
        var dlg = SP.UI.ModalDialog.showWaitScreenWithNoClose("Waiting!", "Processing...");
};
var defd;

try {
     defd = typeof SP.UI.ModalDialog.showWaitScreenWithNoClose;
}
 catch (e) {
        defd = "undefined";
}
EnsureScript("SP.UI.Dialog.js", defd, fn);

And the result is:


Conclusion: To work with API client SharePoint object model, we must ensure the scripts loaded!

Tuesday, April 15, 2014

Update: How to SharePoint 2013 resolve saving conflict when updating item in Discussion Board

If you are developer and try to update something in the list/site, you will get the error sometime lile this:

Save Conflict
Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes

However, SharePoint 2013 has been fixed this issue by using loop statement to save again. Try 5 times to avoid the conflict saving data.
using (new SPMonitoredScope(string.Format(CultureInfo.InvariantCulture, "HandleSaveConflict for method: {0}", new object[] { action.Method.Name })))
    {
        int num = 0;
        while (num < 5)
        {
            try
            {
                action();
                return;
            }
            catch (SPException exception)
            {
                ULS.SendTraceTag(0x220191, ULSCat.msoulscat_WSS_General, ULSTraceLevel.Verbose, "Save conflict in Discussion update: " + exception.Message);
                if ((num == 5) || !SPUtility.IsSaveConflictException(exception))
                {
                    throw;
                }
                Thread.Sleep(100);
                num++;
                continue;
            }
        }
    }

That's s cute and funny. But that's fine. Learn from #Microsoft #SharePoint team to update the list somehow. Like it!

Thursday, January 9, 2014

Difference between tracking list in SharePoint 2010 and 2013


SharePoint 2010 has 3 kinds of tracking list: Task, Project Tasks and Issue Tracking. To create one of these lists, just go to Site Action and click on More Options. It doesn’t depend on site template completely. The following table is described details of these lists:

Name
Feature ID
List Template
Tasks
{00bfea71-a83e-497e-9ba0-7a5c597d0107}
107
Project Tasks
{00bfea71-513d-4ca0-96c2-6a47775c0119}
150
Issue Tracking
{00bfea71-5932-4f9c-ad71-1557e5751100}
1100

There is a special option in the Advance Setting: Email Nofitication. This option is enabled if the Email Setting in Central Administration has been configured. When this option is set to ‘Yes’, that means the user who has been assigned to by ownership will get the alert by email or the ownership has changed something in that item.

Before to enable Email Notification option, take a look at Item-level Permissions options. To manage user working on the list, the moderator could change this option to allow/disallow user who has permission to read, edit or doing something on list item.
Assume that the user who has not permission to read the item but was assigned by the owner. So, what will happen and how the user could see that item? If you are still feel confused, let see the WAD of SharePoint 2013.
SharePoint 2013 has exposed much more tracking list: Tasks, Task /w. timeline, Issue tracking and GanttTasks. GanttTasks is actually a project tasks in SharePoint 2010 and after exposed with more Tasks /w. timeline then this list to be the default tasks.
Name
Feature ID
List Template
Tasks
{00BFEA71-A83E-497E-9BA0-7A5C597D0107}
107
Tasks /w. timeline
{F9CE21F8-F437-4f7e-8BC6-946378C850F0}
171
Issue Tracking
{00BFEA71-5932-4F9C-AD71-1557E5751100}
1100
GanttTasks
{00BFEA71-513D-4CA0-96C2-6A47775C0119}
150

In the site contents to add a new app, SharePoint 2013 was hidden Tasks (107) and GanttTasks (150). And except for Task with timeline doesn’t have an option Email Notification, all the others tracking list have this option. Thus, if you try to enable this option by programmatically, the alert by email still doesn’t work or work incorrectly.
In sharePoint 2013, to create the hidden list, please change the url and go:
/_layouts/15/new.aspx?FeatureId{FEATURE_ID}&ListTemplate={LIST_TPL_ID}&IsDlg=1
Where: FEATURE_ID is a feature id to work with that list, and LIST_TPL_ID is a list template id.


Friday, January 3, 2014

Announcement: SharePoint Saturday Event 7th & resume SharePointVietNam.NET forum

SharePoint Saturday Vietnam (SPSVN) is a free community focused SharePoint event dedicated to educating and engaging members of the local technical community. SPSVN draws upon the expertise of local SharePoint IT professionals, developers, and solution architects who come to together to share their real world experiences, lessons learns, best practices, and general knowledge with other like minded individuals.

SPS VN 7th will be held on Saturday, Jan 11th, 2014. The agenda and information you will find on http://sharepointsaturday.vn


Location of SPS VN 7th


For SPS Vietnam, I was speaking at the event with some topics to help developers and administrators work with the best practice:

  • 1st: All about the Ribbon of SharePoint 2010
  • 4st: The Best Practice SharePoint Developing
  • 5th: The Best Practice SharePoint Farm Installation
  • 6th: Improve performance and security with best practice for SharePoint WP/App

In 2014,  I will share a lot of articles about SharePoint 2013 apps for developing with trying my best. In the community, I also try to join the SPS VN discussing about the growing SharePoint apps in VN and then resume the forum for all Vietnamese SharePointers. If you have any question or something good idea you could share in the forum. This forum is a free community and don't hesitate posting on that. I (and another people) will follow and reply as soon as possible.



Thursday, January 2, 2014

Could not run the SharePoint Wizard Configuration after install the hotfix?!

SharePoint 2013 takes so long time to install and configure the CU hotfix, it took more than 5 hours for me to install. I actually increase the RAM to 16GB but the problem is not improved and more and more longer than usual. Eventually, you do not need to install the CU hotfix for August 2013, just install March, October and December 2013. That's all. If you still feel unconvinced with the duration of installing, you could see to stop the service and run the PS command as link helping bellow:

http://blogs.msdn.com/b/russmax/archive/2013/04/01/why-sharepoint-2013-cumulative-update-takes-5-hours-to-install.aspx

Somebody thought that could be install all the hotfix then after all run the wizard configuration, of course could do something like that, but at the end the error will happen if you run the SharePoint Wizard Configuration:


Don't worry about that, just do it as your best and do not need to run the wizard as normally. Just run the command by command line:

psconfig.exe -cmd upgrade -inplace b2b -force -cmd installcheck -noinstallcheck

Here is the blog to explain about the above command:

http://blogs.msdn.com/b/fabdulwahab/archive/2013/03/04/missing-hot-fixes-sharepoint-2010-configuration-wizard.aspx

Tuesday, August 20, 2013

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.

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.

Monday, July 16, 2012

Download SharePoint Server 2013 for preview


There are some new app as a required installing for SharePoint 2013 Microsoft SharePoint Server 2013 system requirements
Here's the Installation Key for SharePoint Server: 6RNT8-XV26M-GWH36-VMGQH-94MMH
The first blog for SharePoint 2013: How to Install SharePoint Server 2013
SharePoint Foundation 2013 Preview
Language Packs for SharePoint Foundation 2013 Preview – English, Japanese, and Spanish
Filename: SharePointFoundationLP_en-us_x64.exe
Download Microsoft SharePoint Server 2013 Preview
Language Packs for SharePoint Server 2013 Preview – English, Japanese, and Spanish
Filename: serverlanguagepack_en-us_x64.exe
SharePoint Designer 2013
They always release 2 version of SPD: 64 and 32 bits
Filename: sharepointdesigner_en-us_x64.exe
Filename: sharepointdesigner_en-us_x86.exe
SharePoint 2013: presentation: IT pro training