Tuesday, July 9, 2013

SharePoint list migration

There are many ways in which you can migrate SharePoint lists between sites or servers. One of my favorite is by using gl-exportlist and gl-importlist commands created by Gary Lapointe.

With this commands, you can easily export all list items and settings (users and groups) and import them afterwards on a different SharePoint list. 

Follow these steps for list export-import:

1. Start Command Prompt (with "Run as administrator")

2. Write following command to position to right location:



cd "c:\Program Files\common files\microsoft shared\web server extensions\14\bin"


NOTE: In this path, number 14 (marked in red) is for SharePoint 2010. If you are working with SharePoint 2007, then you need to write number 12 instead of 14 in that path. If you are working with SharePoint 2013, then you write number 15 instead of 14 in that path.


3. EXPORT - Write following command to begin export of data: 


.\stsadm -o gl-exportlist -url "http://yourServerName/yourSiteName/yourListName/Forms/AllItems.aspx" -filename "c:\MyDocs" -includeusersecurity -versions 4 -nofilecompression


NOTE: "c:\MyDocs" is a folder on a local disk. If it doesn't exist, it will be created automatically. In the url "http://yourServerName/yourSiteName/yourListName/Forms/AllItems.aspx" you should put the correct url to existing view of your list (put correct server name, site name and list name.

If data has been exported successfully, you'll see screen similar to this one:


And all data is now located on the local disk in the *.dat files.


4. IMPORT - Write following command to begin import of data into another place:

.\stsadm -o gl-importlist -url "http://yourServerName/yourSiteName/" -filename "c:\MyDocs" -includeusersecurity -updateversions 2 -nofilecompression -retargetlinks -sourceurl "http://yourServerName/yourSiteName/yourListName/Forms/AllItems.aspx"


 If data has been imported correctly, you'll see screen similar to this one:

 


More info on these commands:
http://blog.falchionconsulting.com/index.php/2007/09/importexportcopy-lists/


Wednesday, July 3, 2013

SharePoint 2013 - Alert button not visible in SP Ribbon

When I first started SharePoint 2013, I noticed that the "Alert Me" button was missing from library tab in SharePoint Ribbon. KQWZ72KYZTUG



 

First, I tought, that this functionality was removed from SharePoint 2013, but it isn't. It is still there, but the button isn't visible because Outgoing Mail settings are not configured in the server farm.


Outgoing Mail settings can be configured by follwing:
Central administration --> System Settings --> Configure outgoing e-mail settings (under E-mail and Text Messages).



On the next screen fill in the necessary data:




After that, "Alert Me" button should now be visible in library tab in SP Ribbon.

Monday, July 1, 2013

SharePoint - Get list items with javascript

There are many ways of fetching list items of a SharePoint list. The best way to do this is by using c# code, but it is also possible to do it by using javascript, i.e. using jQuery library called SPServices.

NOTE: This post describes code that is used in older versions of SharePoint. If you are using SharePoint 2013, then check out this post.

SPServices is a jQuery library that uses SharePoint web services and it is extremely easy to use. I would always advise to use c# code, but, if you're working on a small scale project that has no need for complex developer solutions, this is a quick and fast fix. You can just add it to your aspx page in SharePoint Designer.

This is the code (this example is taken from Codeplex):

<script type="text/javascript" src="filelink/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="filelink/jquery.SPServices-0.6.2.min.js"></script>
<script language="javascript" type="text/javascript">

function GetAllItems() {
  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Announcements",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
        var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
        $("#tasksUL").append(liHtml);
      });
    }
  });
}
</script>
<ul id="tasksUL"/>


This example will return all items from SharePoint list "Announcements", but, you can restrict the number of rows that it will return, select desired fields that you wish to return or sort them as you wish by modifying CAML query in in this function.