Tuesday, 26 August 2014

What Does Check-in/Check-out Mean?



Check-in and check-out are common terms in many document management systems, including SharePoint. Their purpose is to prevent conflicts in an environment where multiple people might want to edit the same piece of content (in SharePoint, list items or files) at the same time. The term check-in describes the process of adding a new or modified item or file to a document library or a list to replace the previous version. The term check-out describes the process of getting a version of a document or list item in a list or library. By checking out an item or a file, a user can prevent others from editing that content. By checking in the item, the user can allow others to edit the content, without needing to worry about overriding changes that others have made.

Usually when an item or a file is checked out to a user, that user can work on that item or file, and other users cannot. Other users must wait for the user to check in the item or file again (that is, perform a check-in) before they can edit the item or file. While the item or file is checked out, other users usually can see only the last version that was checked in; they can't see the changes that the current user has made on the file while it's been checked out.


Pages in SharePoint can be in document libraries—and often are. This means that pages can be checked out and in, allowing page editors to change a page (for example, add or remove a web part), but the users cannot see the changes until that editor is happy with the changes and checks in the page.

Remove the title column from a Sharepoint list



Recently I was given a task that "How we can remove the 'title' column from a sharepoint list". Initially I thought that "title" being a column in the list can be removed using the list settings and just clicking the check box in front of it. It did hide the columns from the list but when you create a new item it shows up again depending on the order that you have set for the columns. And top of that by default this is the required column. So an item in a list cannot be added until you specify value for "title" column.




this is irrespective of the settings in the default view of the list


So if you want to remove the "title" column permanently, follow the steps given below:
1.  Go to the Settings->List Settings->Advanced settings
2.  Check the "yes" Radio button for "Allow management of Content types" and hit OK 



3. Step 2 will give you "Content types" option on the settings page which will have "Item" content type


4. Clicking "Item" will give following page


5. Clicking on the "Title" will give the screen where you can hide the column completely for future use. Click on "Hidden" under "Column settings" option in this page and hit OK.



6.  Now go back to the list and add a new item and you won't see the "Title" column.  




Monday, 21 July 2014

Error: Please enter a valid choice value. It must not be greater than 255 characters.


In SharePoint 2013, we can create Choice Type list columns as illustrated in the figure below:


No problem with this approach. And we will have an interface to entry in the list as shown below:



This post is related to the Choice field value. In above example, we have used two values as services are "24 Hours Nursing" and "Physical Therapy". And find no problem while creating the list. But suppose we want to use some larger text as values. For example,

"End of Life Comfort and Care - We have a private area of the facility designated for your care. Specialized programs include soothing music and calming aromatherapy in addition to other tactile, sensory and cognitive activities. We desire to provide love and support for you and your family during this difficult time; and provide a peaceful environment for comfort and rest."

and

"20 Bed Ventilator Recovery Suite - specializing in working with ventilator patients that have been deemed vent dependent. We have a progressive weaning protocol that helps facilitate patient weaning at their own rate. All of our patients’ progress is remotely monitored through our state-of-the-art monitoring system, which provides real-time data and frees up the need for multiple blood gas draws."

As in the first figure we put the choice values as below:



As soon as we pressed the Ok button it will generate the error below:



So, Choice field value must not be greater than 255 characters in SharePoint 2013 .

Wednesday, 16 July 2014

Apps in SharePoint 2013


By 
PratapReddyP , 8 May 2013
------------------------------------------------------------------------------------------------------------

Why Apps? What's wrong with Solutions?

The world is getting smaller day by day, thanks to technology. Big desktops became Bulky laptops. Bulky laptops became Notebooks. Notebooks became Ultra books. Now the trend is moving towards Tablets and Smart phones. So does our applications. Web applications becoming Apps. "Apps" is not just a marketing strategy to increase use of SharePoint in wider markets, but also a complete replacement of sandbox approach with many other Pros for both Development, Deployment and Usage.

Do you know that sandbox solutions are deprecated in 2013?

Sandbox Solutions are introduced in SP 2010 and now they are off, to encourage the usage of Apps. May be we should understand the seriousness of Microsoft towards "Apps" in future. Of- course the conventional SP solution approach is still there.

SP 2103 Development Options

  1. Full-trust SharePoint Solutions (WSP)
  2. Apps

Main reasons for "Apps" development

  1. Custom code will not be executed on server. So this can avoid, Application / Server outages.
  2. Custom code will be executed in Client-Browser or may be in some other scope like IIS or Windows Azure, which is completely out of SharePoint scope.
  3. Server Object Model (SOM) code is replaced by Client side object model (CSOM) / Rest Services using which Apps can communicate with Server. Authentication is done by OAuth.
  4. Installing / Updating / Uninstalling of apps can be done without  affecting the SharePoint site.
  5. Better usability in Tablets and Mobile devices.
  6. Taking SharePoint to next level in terms of  Usability, Development, Deployment  and  Hosting(cloud).
  7. Finally, everything in SharePoint 2013 is an App.
I know, the next question is "Most of these reasons are just sounding like reasons for Sandbox Solutions?" Well I have a question for you, how many times we have chosen sandbox solution for real-time implementation?
  1. No full object model . . .
  2. Understanding of Sandbox architecture
  3. Not an easy task to create proxies for execution of full trust code.
What ever may be the reason, real-time applications are tough to develop using a Sandbox solution. That is why "Apps" are introduced in SharePoint 2013 for ease of development and deployment.

Hosting Options in Apps

  1. Provider-hosted
  2. Hosted in the cloud (Windows Azure autohosted)
  3. Hosted in a SharePoint environment
  4. Several combinations of these options.

How apps for SharePoint Work

In above case, App1 is a Provider-hosted or a Cloud-Hosted (Auto-Hosted) app and App2 is a SharePoint Hosted App. So anything related to App1 will be created/Maintained in respective locations, either on Provider or Azure servers. This makes App1 safe and secure in execution perspective.
Now we need to look at App2.
When you create/Imported/Added a SharePoint-Hosted App, it will create a separate sub-web under your SP Web application. This app will be executed in a separate App Domain different from Farm App Domain. So, as process runs under App Domains, any exceptions in Apps will not cause any Outage to SharePoint Farm.

Tuesday, 15 July 2014

Service Unavailable HTTP Error 503 while opening Central Administration in SharePoint 2013



There may be scenario that you are trying to open Central Administration on your browser and getting the following error:




Specially, in the VM environment, if you don't properly shuts down  before closing the days work, the service required to run Central Administration get stopped. To fix the problem,

 Go to -> IIS Manager -> Application Pools

You will observe the following screen:


Observe the SharePoint Central Administration v4.0 service is stopped for some reason. Just right click on the service and start it as follows:


Now observe that it is started as below screenshots:



Run the Central Administration again and you will observe it is working properly as follows:





That's it. Happy SharePointing....!!





Optimizing your SharePoint Development VM for Solid State Drives (SSDs)

Once you upgrade to a Solid State Drive, there is no going back. Your VMs boots faster, your package deployments take mere seconds, and everything feels the way it should. Unfortunately there is a major drawback to a SSD, its lifespan.
Traditional Hard Drives are measured by “Mean Time Between Failures”, indicating the average lifespan of the drive in hours. As a reference point, TheWestern Digital Red NAS drive has an MTBF of 1 million hours.
Solid State Drives have a maximum number of times that each block can be written to. Once a block has reached its limit, the drive often fails with data recovery being next to impossible. To mitigate this problem, SSD controllers use a technique called Wear Leveling to help distribute which blocks are written to on any given IO operation. From my personal experiences, I have had my SSDs die after approximately 12-13 months.
To help reduce the unnecessary writes and to improve your SSD’s lifespan, the following can be done. Please note that these recommendations are strictly for personal Development VMs.
Disable Disk Defragmenter

Because SSDs can access the data directly (unlike HDDs that require seeking), defragmenting a SSD will not provide any performance improvement. However, it will cause a lot of unnecessary writes to your drive. Windows will automatically disable defragmentation when it detects an SSD, however Virtual Machines don’t always know what physical storage the Virtual HDs are running on. Turn off Scheduled Defragmentation to play it safe:


  • Windows 2008 R2
    1. Win Key + R
    2. %windir%\system32\dfrgui.exe
    3. Ensure that Scheduled defragmentation is turned off
  • Windows 2012
    1. Win Key + R
    2. %windir%\system32\dfrgui.exe
    3. Change settings
    4. Uncheck Run on a schedule
    5. Save & Close
Turn off SharePoint Logging
SharePoint ULS Logging is invaluable when troubleshooting a problem or observing a particular behavior, but otherwise the logs aren’t checked daily. I recommend turning on logging in your development environment only when needed. To disable diagnostic logging:

  1. Open Central Administration
  2. Navigate to Monitoring in the left navigation
  3. Click on Configure diagnostic logging
  4. Click on the checkbox next to All Categories
  5. Select None from both of the dropdowns at the bottom of the section
  6. Save and close
If you need to restore your logging, you can follow the same steps and select Reset to default from the dropdowns.
Disable Search Indexing
Independent of SharePoint’s search engine, Windows has its own search index. Disabling Windows Indexing can save some I/O, but it really comes down to personal preference. I like to keep my development environment well organized by client & project, and do not have files scattered all over the place. Disabling the index will allow for a slightly slower search to occur, which isn’t a problem since my scope is a specific folder. To disable Windows Search Indexing:

  1. Open Windows Explorer and navigate to Computer (Win 2008) or This PC (Win 2012)
  2. Right click on your Local Disk (C:) drive and click on Properties
  3. Uncheck Allow files on this drive to have contents indexed in addition to file properties
If you have any other tips & tricks that have worked well for you, please let me know!

Monday, 14 July 2014

WorkAround: Hybrid Approach to Create and Update SharePoint 2013 List from Excel Sheets for large volume of data.

Introduction


In many organizations the management people in any department use Excel to maintain their records, data, history etc. And now a days SharePoint based applications are often used to share and collaborate these files. Many organizations use SharePoint sites as their portal sites for the purpose of sharing information, data within department or organization.


Problem


So now let’s say your manager or client has an Excel sheet with valuable records and now he/she wants to put it on the SharePoint as a list, and asked you to do that. Now what will you do? You cannot use Excel services nor upload excel sheet as it is (even though you can  ) because manager wants SharePoint list only. As a SharePoint developer you will think : first create a SharePoint List and then write one tool which will read Excel sheet records one by one and add it to the SharePoint list. Right? But is it really needed if SharePoint and Office provides it itself? 


Solutions


1. From Excel Sheet


Yes you can quickly create SharePoint List out of Excel sheet without writing any single line of code. Let's see how we can do. Note: I have performed these steps on SharePoint 2013 with Microsoft office 2010.
Steps:
  1. Open the Excel 2010 application.
  2. Insert/create the table. 
     


3. Pressing OK button will generate the below scenario:



4. Pressing the above link will give you the below screen where you need to put the value of a SharePoint application running at your environment, name of the list and description of the list(optional) as shown below:




5. Pressing Next will cause the following Login screen to appear:


6. Press OK and  On the next screen you will see columns with data types which are going to create in SharePoint list.







        



    7. Now click finish and wait until the operation gets finished. You will see that list gets created in SharePoint site with the records.    

        





That's it. 

   

2. Using Import SpreadSheet App


SharePoint 2013 provides 'Import SpreadSheet App' to do the same thing. Follow below steps to import SpreadSheet.

1. Go to Site Contents -> add an app, and search for 'Import SpreadSheet' app.

            
  

2.  Add 'Import SpreadSheet' app and provide information as shown in below screen. You need to select the excel file. [Before that you need to save the excel file in table format as shown in Approach 1.]

        

3. Click on the import, wait for few seconds and your spreadsheet gets imported in list.

        

That is also fine.

But the problem is in both of the above cases, the generated list is completely new with the data on the excel sheet. But how to handle the scenario when there is an old list and you need to update the list from an external excel sheet without loosing the previously stored data. For this reason, we need to programmatically read the newly created list and insert into our target list which can be done by a simple visual web part and on a button click. The click event and the function written  for this purpose is given below which I have applied as a workaround to solve the problem. Below are the source code samples:

 protected void btnUpload_Click(object sender, EventArgs e)
        {
       

            SPSecurity.RunWithElevatedPrivileges(delegate
                {
                    try
                    {
                        
                        LoadData();
                    }
                    catch(Exception ex)
                    {
                        Logger.Current.Log("Error: " + ex.Message);
                    }
                });

        }

        public void LoadData()
        {
            try
            {
                SPWeb spWeb = SPContext.Current.Site.RootWeb;
                SPList spList = spWeb.Lists.TryGetList("MyList");

                SPQuery qry = new SPQuery();
                string camlquery = "<OrderBy><FieldRef Name='Created' /></OrderBy>";
                qry.Query = camlquery;
                DataTable listItemsTable = spList.GetItems(qry).GetDataTable();

                SPList oList = spWeb.Lists["Employee"];
               

                foreach (DataRow dr in listItemsTable.Rows)
                {
                    SPListItem oSPListItem = oList.Items.Add();

                    oSPListItem["Title"] = dr["Title"].ToString();
                    oSPListItem["Designation"] = dr["Designation"].ToString();                  
                    oSPListItem["Address"] = dr["Address"].ToString();
                    oSPListItem["Salary"] = Conver.ToInt32(dr["Salary"].ToString());
                    oSPListItem["Email"] = dr["Email"].ToString();
                    oSPListItem["PhoneNumber"] = dr["PhoneNumber"].ToString();
                    oSPListItem["Organization"] = dr["Organization"].ToString();
                    

                    oSPListItem.Update();
                    
                }

                lblMessage.Text = "Data inserted successfully";
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.ToString();
            }
        }




Finally create a page  in your web application and add the visual web part to have a visual interface to click on and update SharePoint list from excel sheets dynamically.


Happy Share Pointing...!!!