Wednesday, June 8, 2016

Migrating Lists with Lookup Fields

One of the basic activity while working on SharePoint site is to migrate lists/libraries from one site to another. If you have a lookup field in the list then the task is not basic anymore. 

I faced this issue several times. I never gave it a thought and always used to recreate the list at destination site. But recently I stumbled upon a blog from Maulik Dhorajia who has described this issue in detail. 

In my case, I was moving 3 lists & 1 document library. This 1 doc lib had reference (lookup column) to other 3 lists. All the steps were same except I had to add all document in the VS 2013 project along with the manifest.xml file.

Below are the steps in brief...

  1. Create list templates with content,
  2. Create parent lists in destination site,
  3. Note down list GUID for the newly created list,
  4. Rename doc lib the stp file to .cab,
  5. Extract the manifest.xml file,
  6. Look for the old list id and replace it with new list id,
  7. Create a new project in VS - CAB Project. I had to download the template from Microsoft site,
  8. Add all the documents along with manifest.xml file to the project. If you are migrating a list, then you will only have manifest.xml file,
  9. Build the project, go to debug\bin folder,
  10. Find the .cab file and rename it to .stp,
  11. Upload the template to the gallery & create a list/library out of it,
  12. That's It.
Its a bit of workaround, but if you have a large list then this is your saviour. 

Wednesday, May 25, 2016

Javascript/JQuery Handle Double Click

Recently I have been working on JavaScript/Query & SharePoint client side extensively. I will be posting my learnings during the past one year in the coming few posts. 

Recently I was presented with a problem that the custom solution I had provided, did not behave properly when double clicked. 

Scrapping through the web, I fumbled on couple of solutions. I personally like the first approach as it is very simple. 

First Approach:
Click Me

$("#clickMe").click(function (e) {
    var $this = $(this);
    if ($this.hasClass('clicked')){
        alert("Double click");
        //here is your code for double click
        //your code for single click
         setTimeout(function() { 
                 $this.removeClass('clicked'); },500);
    }//end of else

Second Approach:
var DELAY = 700, clicks = 0, timer = null;


    $("a").on("click", function(e){

        clicks++;  //count clicks

        if(clicks === 1) {

            timer = setTimeout(function() {

                alert("Single Click");  //perform single-click action    
                clicks = 0;             //after action performed, reset counter

            }, DELAY);

        } else {

            clearTimeout(timer);    //prevent single-click action
            alert("Double Click");  //perform double-click action
            clicks = 0;             //after action performed, reset counter

    .on("dblclick", function(e){
        e.preventDefault();  //cancel system double-click event