Thursday, 02 May 2013

Many people complain about SharePoint personally I haven't had much of a problem with it in the past until now. The theory of SharePoint is sound, it's a good idea and I was an early SharePoint Developer back in the days of version 1.

The main problem with SharePoint I find these days, is actually getting teams to use it. I have worked with a lot of companies in the past and many have it installed. However there appears to be a key issue in SharePoint which makes it harder for people to use and I've seen it on several sites.

How can I easily copy my documents up to SharePoint?

Any SharePoint dev or person who has used it will say "Oh just click on the explorer view". The explorer view is great for getting documents into SharePoint provided it actually works. You can also map a network place to a folder in SharePoint, however this also suffers exactly the same problem. It doesn't always work!

The frustration!

Visit the Microsoft forum's and its full of people asking the same questions who are being presented with all kinds of work arounds. From ensuring certain services are turned on, to adding SharePoint to your trusted sites right down to wiping all of your browsing history. For some this works but for quite a lot this just doesn't work. For the end user this is frustrating, they may not be very technical and it takes time out of their day. The main question on their minds is "Why can't it just work?". These users who experience these issues usually raise the problem with their tech support desk who find themselves in a difficult predicament. What usually happens is people come up with their own solutions to problems and some of them involved bypassing SharePoint and just placing the final document in there while they make use of tools such as DropBox, SkyDrive (the irony) or Email to share documents.

Get it right

Surely Microsoft understands that this is such a vital part in getting people to use SharePoint. They need to get this bit right and it should just work with no questions asked. The result of this not working is one (not all) of the reasons I hear people saying so many unfavourable things about SharePoint. Microsoft if you get this bit right you're going to see some happier people.


Note
I am awaiting the next version of Office 365 & SharePoint with interest, if this issue is addressed here it will be a huge leap forward.

posted on Thursday, 02 May 2013 10:10:46 (GMT Standard Time, UTC+00:00)  #    Comments [0]

 Thursday, 19 July 2012

I've posted this for my on reference more than anything else.

Basically if you are trying to work out the value and text of a dropdown list inside a SharePoint list this is the syntax

 

listDataFromServer[i].get_item('clients').get_lookupId()      - This will return you the value

listDataFromServer[i].get_item('clients').get_lookupValue()  - This will return you the text from the dropdown list.

posted on Thursday, 19 July 2012 14:31:18 (GMT Standard Time, UTC+00:00)  #    Comments [0]

 Friday, 29 June 2012

I thought I'd post this for my own records so I have somewhere to refer back to it. I've also posted it because there was very little help regarding the problem on the Internet and the workarounds proposed weren't that nice. Many ranged from hacks that involved forcing the page to reload itself or having to use CAML instead.

Anyway here is the scenario, the text book piece of code below is used to update a list item in SharePoint using JavaScript. Everything works fine, however if someone else updates a record on another machine after you and then you update the same record on your machine you'll get the "Version Conflict" error.

 

   1:  function updateListItem(id, statusField, valueToChangeTo, listName, newparentId, parentField) {
   2:            
   3:            var ctx = SP.ClientContext.get_current();
   4:   
   5:            var list = ctx
   6:                      .get_web()
   7:                      .get_lists()
   8:                      .getByTitle(listName);
   9:   
  10:              var item = list.getItemById(id);
  11:                 
  12:             item.refreshLoad();
  13:           
  14:             item.set_item(statusField, valueToChangeTo);
  15:             item.set_item(parentField, newparentId);
  16:   
  17:             item.update();
  18:            
  19:            ctx.executeQueryAsync(function () {
  20:                console.log("New value: ", item.get_item(statusField));
  21:            })
  22:        };

 

So what went wrong?
Well basically the object that you're accessing is a cached object, you retrieved on the first time you saved the item. Since someone else changed the object before you this time your cached object is going to cause a version conflict as SharePoint as a newer version of the item.

How do I solve the problem?
You need to load the object again and then update it.

   1:  function updateListItem(id, statusField, valueToChangeTo, listName, newparentId, parentField) {
   2:   
   3:            var ctx = SP.ClientContext.get_current();
   4:   
   5:            var list = ctx
   6:                      .get_web()
   7:                      .get_lists()
   8:                      .getByTitle(listName);
   9:   
  10:            var item = list.getItemById(id);
  11:   
  12:            ctx.load(item)
  13:   
  14:            ctx.executeQueryAsync(function () {
  15:   
  16:                updateListitemAfterData(item, statusField, valueToChangeTo, parentField, newparentId);
  17:            })
  18:        }
  19:   
  20:        function updateListitemAfterData(item, statusField, valueToChangeTo, parentField, newparentId) {
  21:            var ctx = SP.ClientContext.get_current();
  22:            item.set_item(statusField, valueToChangeTo);
  23:            item.set_item(parentField, newparentId);
  24:            item.update();
  25:   
  26:            ctx.executeQueryAsync(function () {
  27:   
  28:                console.log("New value: ", item.get_item(statusField));
  29:            })
  30:   
  31:   
  32:        }
So in the code above I call updateListItem with my values. This then goes and loads the list item fresh from SharePoint and waits using an async call. Once it gets this async call it calls updateListItemAfterData to do the actual saving for us. Please note in the above example you may want to pass the context or to declare it globally instead to be more efficient.  

So far the above solution appears to be working for me, with no version conflicts Smile

posted on Friday, 29 June 2012 12:12:47 (GMT Standard Time, UTC+00:00)  #    Comments [0]