Tuesday, March 19, 2013

Best Practices Presentation and App Project from SharePoint Extreme 2013

Hello All,
These are links to download my presentation and Apps Projects from my latest Presentation in the SharePoint Extreme 2013 Conference.


Hope you have enjoyed!

Monday, October 29, 2012

SharePoint 2013 REST Overview via JavaScript - Part 1

Hello everybody,
This is the first technical article i'm writing about SharePoint 2013, and i've chosen to start with a combination of REST and JavaScript because, I've been getting more and more comfortable with the idea of developing application with more and more client site code.

I also think that it can make the new platform a lot more comfortable to play with using some simple JavaScript.

Starting with a simple contex, to get anything from REST, you need to add '_api' to the web site url, followed by an object type.

This is the first article in a series covering using REST with JavaScript and will be updated as the new articles are published.

  •  SharePoint 2013 REST Overview via JavaScript - Part 1 (Reading data with REST)


The following are examples of using REST api

http://[site url]/_api/site
Get the site collection information.

http://[site url]/_api/web
Get the web site information.

http://[site url]/_api/lists
Get the information on all lists in the web site.

You can type thses URLs in the url address bar and get the xml containing the information (if you have a problem viewing the xml, just click "View Source")

Next, we'll see how to use these url to get information into JavaScript objects.
We will use jQuery.ajax to get the information.



Getting SharePoint List information using jQuery
// Getting the xml information on all the lists in this site
jQuery.ajax({
   url: "http://site url/_api/web/lists",
   type: "GET",
   headers: { "Accept": "application/json;odata=verbose" }
});

// Getting Information on a specified list by its title
jQuery.ajax({
   url: "https://site url/_api/web/lists/GetByTitle('Documents')",
   type: "GET",
   headers: { "Accept": "application/json;odata=verbose" }
});

// Getting information on a all items in a curtain list
jQuery.ajax({
   url: "https://site url/_api/web/lists/GetByTitle('Documents')/items",
   type: "GET",
   headers: { "Accept": "application/json;odata=verbose" }
});

// Getting information on a specified list item by it's ID
jQuery.ajax({
   url: "https://site url/_api/web/lists/GetByTitle('Documents')/items(17)",
   type: "GET",
   headers: { "Accept": "application/json;odata=verbose" }
});

// Getting a collection of properties on a list item
jQuery.ajax({
   url: "https://site url/_api/web/lists/GetByTitle('Documents')/items(17)?$select=Title,Modified",
   type: "GET",
   headers: { "Accept": "application/json;odata=verbose" },
});

The xml returned from:
"https://site url/_api/web/lists/GetByTitle('Documents')/items(17)?$select=Title,Modified"
is this:

After getting the XML you can handle it and use it as you want using XML Parsing or JSON:
// Getting a collection of properties on a list item and popping a message with the list item's title
jQuery.ajax({
   url: "https://site url/_api/web/lists/GetByTitle('Documents')/items(17)?$select=Title,Modified",
   type: "GET",
   headers: { "Accept": "application/json;odata=verbose" },
   success: function (data) {
      var jsonObject = JSON.parse(data.body);

      alert(jsonObject.d.Title);
   }
});


References

Basic Operations on 2013 REST:
http://msdn.microsoft.com/en-us/library/jj164022(v=office.15).aspx#ClientAPIs

2013 REST on MSDN:
http://msdn.microsoft.com/en-us/library/fp142380(v=office.15).aspx
http://msdn.microsoft.com/en-us/library/fp142385(v=office.15).aspx
http://msdn.microsoft.com/en-us/library/fp142386(v=office.15).aspx

Choose the right API set for SharePoint 2013:
http://msdn.microsoft.com/en-us/library/jj164060(v=office.15).aspx

Monday, October 15, 2012

Activating Sharepoint 15 Workflow Office Extension Feature

Apparently this feature can't be activated without an installation of Windows Azure Workflow Installer (Source).
I kept getting the error 'Failed to instantiate file "WorkflowTaskPane.xml" from module "MOEPageRedirect": The specified list does not exist.' when trying to activate the feature.

Hope this helps anyone with problems.

Wednesday, August 22, 2012

Synchronizing Content Between Farms on SharePoint 2010

Hello All,
In this post I'm going to give a concise review of all the solutions I've came across that enable Copying and Synchronizing content between SharePoint Farms (also Deploying Content Between SharePoint Farms) mainly for the purpose of migrating developments and implementations between environment once they have changed.

These solutions are relevant for SharePoint 2010 and provide a collection of articles and links to make the decision more comfortable.

Why?
First off, I wanted to do this post because I've heard many clients that ask me about the right way, wrong way and best way. The truth is like always, it depends.

First Migration
When developers first intend to migrate a solution between environment they would usually choose to perform a backup\restore of the Site Collection using Backup-SPSite and Restore or using Export-SPWeb and Import-SPWeb.
I personally like to use the backup\restore approach.
If the given site is particularly large and contains many developments\implementations I always try to plan and build the site in a separated Content Database and add that content database to the target environment.

Backup\Restore
Here are a few helpful links on the matter (best examples I found were on MSDN):
Backup: http://technet.microsoft.com/en-us/library/ff607901.aspx
Restore: http://technet.microsoft.com/en-us/library/ff607788.aspx

Export\Import
http://secretsofsharepoint.com/cs/blogs/tips/archive/2010/09/17/importing-amp-exporting-sites-in-sharepoint-2010-using-powershell.aspx

The big differences:
Backup\Restore will move all your data and rights, plus, it will create the corresponding records in the content database. Export\Import is quite a different approach. It will export all the file, data and metadata into a cab file from which it will import and create the new content. You can use it only for web sites (not site collections). It can also move the site security as well if you set the corresponding flags. Check the other options to see the different options

Add a new Content Database:
technet.microsoft.com/en-us/library/cc825314.aspx

Move SharePoint Site between Content Databases:
http://technet.microsoft.com/en-us/library/cc825328.aspx

Detach Attach Content Database:
http://drekendrop.blogspot.co.il/2011/03/sharepoint-2010-detach-sharepoint.html

Site Templates
Another approach I see sometimes taken is saving the site as template and creating a site from that template in the destination environment (Thanks to Ohad Ben-Shalom for pointing that one out).
You can also achieve that on a site collection by creating a new site collection and later choosing the template:
http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=218

Keeping it all Synchronized:
Mainly, there are 3 main approaches:
  1. Content Deployment Job (Manual)
  2. Open Source Solution (Manual)
  3. Third Party Solutions (Manual\Automatic)
All of the solutions I will present here are based on the Export\Import Object Model provided by SharePoint. This is also the same method stsadm -o export\import and Export\Import-SPWeb (PowerShell) use when run from the console.
For more information click here: SPExport and SPImport.

The big difference between each approach is how flexible it is against how much effort you would need to suite it to your needs.

Approach Cost Flexibility Pro Con
Content Deployment OOTB None OOTB and little configuration No Flexibility\granularity. Content will have to stay identical to source environment
Open Source None Very Very flexible and can be changed according to client needs Required Programmers for development
Third Party Solutions Varies Highly flexible (you can probably find any need you might have answered by one or another product) No code, flexible, comfortable Can reach very high cost. You might depend on company's customer care.

Solutions

SharePoint Content Deployment Job
When to use and how to prepare to use Content Deployment (MSDN):


How to define Content Deployment:
According to Technet you can perform the following actions between farms so long as they have trust relationship between both domain and farms.

Pros:
  • Easy to use
  • Out of the box
Cons:
  • The content in the target environment will always have to remain identical to the content in the source environment
  • No Flexibility
Usage of Open Source Code and Code in General
SPDeploymentWizard from CodePlex (includes a user interface): 
Including a set of PowerShell Functions for performing Export\Import between sites.

Examples of how to use SPExport and SPImport from MSDN:

Third Party Solutions
I've came across mainly 4 third party solutions:

AvePoint DocAve Replicator:

Repliweb ROSS:


Metalogix:

All Products offer basically the same functionality (plus, minus different perks here and there), but what differentiates them one from another is the quality of the product and the support they offer.
Personally I haven't used any of them, but from what I can gather in the market and from all the people I come in contact with, AvePoint company's (DocAve) products do the work and they provide a very high level of customer service and support.

Summary
For conclusion I will give you the way I perform the deployments between environments:
  1. Each project should be checked and planned for individually before development\implementation begins.
  2. It is always preferable to create the site as a new Site Collection (and if there is sufficient need you can create the Site Collection on a new Content Database)
  3. First Deployment\Migration with Backup-SPSite\Restore-SPSite (If this is a Content Database you can migrate with DB Backup\Restore or Detach\Attach)
  4. Incremental deployment of content with SPDeploymentWizard.

Please feel free to comment on this post with experiences you've had with products and how you work when synchronizing between environments or you disagree with what I wrote.

Hope you found this article helpful.

Thursday, July 26, 2012

Getting All the Groups of a User with JavaScript in SharePoint 2010

Hello All,
This week I want to share a nice way to get all the SharePoint Groups of a certain user using javascript.
I tried getting that all the SharePoint Groups of a certain user using Client Object Model, but the solution turned to be quit complicated in comparrison to using SPServices.
(The links for using Client Object Model are located at the end of this post)

The solution using SPServices consists of the following two simple steps:
First, you will need to add the javascript directives to the page:
<script type="text/javascript" src="/Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/Scripts/jquery.SPServices-0.7.1a.min.js"></script>

And Then add the script that will retreive all the groups of the Connected User\Current User:
$(document).ready(function() {
 $().SPServices({
  operation: "GetGroupCollectionFromUser",
  userLoginName: $().SPServices.SPGetCurrentUser(),
  async: false,
  completefunc: function(xData, Status) {
   if($(xData.responseXML).find("Group[Name='GroupName']").length == 1) 
   {
    // Hiding\Showing or other handler when the user is member of GroupName
   }
  }
 });
});


Link for using SPServices:
  • jQuery download:
http://www.jQuery.com
  • SPServices site on CodePlex:
http://spservices.codeplex.com
  • Getting  All Groups of a certain User using SPServices:
http://spservices.codeplex.com/wikipage?title=GetGroupCollectionFromUser&referringTitle=Users%20and%20Groups


Links for Client Object Model solution:
http://msdn.microsoft.com/en-us/library/ff410544.aspx
http://spdailytips.blogspot.co.il/2011/09/get-all-groups-javascriptecmascript.html

Tuesday, July 24, 2012

Updating Texonomy Field Value in C#

Hi All,
This post is a simple one to show how to update Taxonomy Field value with C# code.

If you try to update the field with:
item["Taxonomy Field Name"] = "Term Text"; (Either "Term Text", "Term Guid" or "Term Text|Term Guid")
You will see that the update might work on the first update\try. But, trying to update in the same we the second and third tries will fail.

There are two approached to the solution given here:
// In case you are using a TaxonomyFieldControl
TaxonomyFieldValue taxonomyValue = TaxonomyFieldControl.GetTaxonomyValue(textFieldValue);
Guid termGuid = taxonomyValue.Id;
item["Taxonomy Field Name" + "_0"] = "|" + termGuid;

In case you don't have a TaxonomyFieldControl, you can simply apply the same without it:
// In case you are using a TaxonomyFieldControl
Guid termGuid = new Guid("<The Guid of the term you would like to set>");
item["Taxonomy Field Name" + "_0"] = "|" + termGuid;

If you want to add multiple values you can see the next technet thread:
http://social.technet.microsoft.com/Forums/en-US/sharepoint2010customization/thread/83fd6ba4-7bd3-4241-92f8-1f4948dfb16b/

Thursday, July 19, 2012

SharePoint 2013 Presentations for IT pros

Hello my dear readers.
Happily I can join the fiesta regarding the SharePoint 2013 beta.
 I came across a great link with many How To presentations:
SharePoint 2013 training for IT pros

 Have fun :)