Monday, May 11, 2015

How to get started with Office 365 API Development

Hi All,

I have been asked by clients: How to get started with Office 365 API Development ?
They want to integrate office365 capabilities in their existing systems and applications.

In this blog i am providing links on how to get started with authentication, accessing mail, calendar, contacts and providing an amazing *FREE* training course from MS MVA (Microsoft Virtual Academy) site:


1) Office 365 API platform overview:

2) Samples to integrate with Office 365, specially what you mentioned mail, calendar...etc.:
Check out under Web, It has MVC Web samples to integrate calendar, contacts..etc

3) Office 365 app authentication concepts, this will provide different scenarios to authenticate users against o365 (Important):

4) Great FREE training course for office 365 development training:

5) Calendar, Mail and Contact REST API reference:

Hope this helps, and feel free to send any questions over to help.


Friday, May 01, 2015

My Study notes and guidance to pass 70-532 Exam : Developing Microsoft Azure Solutions

Hi All,

Today i have passed Microsoft exam 70-532 "Developing Microsoft Azure Solutions". I have been studying for awhile. I have been implementing Azure solutions since 2008. The preparation was just a mater of getting the exam materials, focus on the exam topic areas, and do lots of readings!

I will provide all what you need to read, watch or most importantly is my study tips to pass the first exam in the Azure certifications for Developers and Architects.

A) What you need to read:

1) Topics covered in the exam:
https://www.microsoft.com/learning/en-us/exam-70-532.aspx

2) Developing Azure Solutions book (or the ebook):
http://www.amazon.com/70-532-Developing-Microsoft-Azure-Solutions/dp/0735697043


B) What you need to Watch:
Microsoft  Virtual Academy (MVA) has a course for this exam. Amazing course that cover all the basics of this exam, great conversations and discussions for these topics. It covers exam's  topics and lots of demos in the MVA course and  you need to do some exercise for all the topics they asked to read more about.

http://www.microsoftvirtualacademy.com/training-courses/developing-microsoft-azure-solutions


C) My Study notes & tips:




  • How to configure custom domain in your Azure app service:    
          http://azure.microsoft.com/en-us/documentation/articles/web-sites-custom-domain-name/

  • How to configure GIT in Azure for Continuous Integration:
          http://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/

  • How to enable remote debugging for deployed Azure app service:
          http://blogs.msdn.com/b/webdev/archive/2013/11/05/remote-debugging-a-window-azure-web-site-with-visual-studio-2013.aspx

  • How to configure Azure Mobile Push Notifications service:
          https://msdn.microsoft.com/en-us/library/azure/dn167707.aspx

  • Understand the factors that affect the cost (billing) when you store content in Azure CDN Services and how to control it.
  • How to integrate with Azure AD Services through REST API.
  • Understand Azure Storage replication strategies, check out this link:
          https://msdn.microsoft.com/en-us/library/azure/hh873027.aspx
  • How to manipulate data in Azure storage in C#, check out this simple reference:
           http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/
  • How to configure Virtual Networks (VNet) in Azure using Site-to-Site and Site-to-Point, check out this reference:
          https://msdn.microsoft.com/en-us/library/azure/jj156206.aspx


Hope this helps and best of luck for all of you!




Thursday, April 23, 2015

Office 365 Dev Camp is near your city ?

Hi All,

If you are looking to get up to speed in office 365 application development. I have good news for you!

Microsoft is planning to have Office 365 in every major city in US, check out the schedule and save your seat today.

The dev camp is a one day deep dive in building office 365 applications including Office Word, Outlook, SharePoint Apps, Office 365 API and more.

Check out all office Dev Camps events in the below link:

http://aka.ms/msdevcamps


For local friends, The Washington DC office 364 dev camp event will be in 6/1 for Office 365 Dev Camp!


DC office 365 Dev Camp direct link to sign up!



The link above has other dev camps for cloud data and IoT dev camps.


Enjoy!





Tuesday, April 14, 2015

How to fix 'thumbprint' attribute is invalid error in Azure Cloud Service

Hi,

While i was configuring a web role in a cloud service project to use SSL certificate, I was adding my certificate to the Service Configuration file (cscfg) as follows:

  <Certificate name ="MyCertTest" thumbprint="cd947ee0b988e3b144d9fc39af47128dec68b731" thumbprintAlgorithm="sha1"/>
 

After i copied the thumbprint value from my certificate and paste it in the configuration file (cscfg) i found that there is an underlying error under thumbprint attribute and when i build i get the following error:

the xml specification is not valid: the 'thumbprint' attribute is invalid the pattern constraint failed


Here is the steps on how to fix it:

1) Remove any spaces from the thumbprint value.
2) There was a hidden character at the beginning and end of this string and once i removed it the underlying error in the cscfg file went away.
3) Save your changes and build!
4) Deploy your cloud service to Azure.


Hope this helps.


Sunday, April 12, 2015

How to return JSON objects from Web API 2

Hi All,

I was trying to return an object from web api 2.0 and i was getting the following error:

The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.

The inner exception message was stating the following:

Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.


Sample method:

[HttpGet]
[ResponseType(typeof(ChargifyTransaction))]      
public async Task<MyObject> GetTransactionDetails(string transactionId)

{

   MyObject obj = new MyObject();
   obj.Id=123222;
   obj.Name = "Mostafa dev";
   
   return obj;
}

The solution:

Add the following 2 lines in Global.asax file under App_Start method, This will force the web api to return Json formats and to ignore references to itself for Newtonsoft.Json dll.



 protected void Application_Start()
        {
            // Force to use Json formatter and ignore reference looping.
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);


           }


Hope this helps.

Wednesday, July 02, 2014

Understanding, Designing, and Implementing Big Data Solutions in Azure

Hi,

I am writing this blog post to point to an important published article from Microsoft Patterns and Practices Team on understanding, designing and implementing Big Data Solution on Windows Azure using HDInsight.

Want to know what is big data ? what is being used for ? Do you have a need for it ? what is the best scenarios to think about adopting to big data tools?
The answer for these questions are covered under the first section of Understanding Big Data on below link:

http://msdn.microsoft.com/en-us/library/dn749804.aspx


Second section of this article is covering how to design a scalable big data solutions in Azure platform using HDInsight. Would you use big data to explore your data and extract patterns, Apply BI techniques, Build ETL integration tools, Automation data processes all are covered on below link:

http://msdn.microsoft.com/en-us/library/dn749816.aspx

Third section of this article is covering how to using Azure as PaaS to implement your Big Data Solution using HDInsight including how to provision your first Hadoop cluster node and all required configurations for storing your big data files, build end-to-end solutions and visualizing your data:

http://msdn.microsoft.com/en-us/library/dn749874.aspx


Hope this helps!

--ME



Friday, June 13, 2014

How to: Create ASP.NET MVC Authentication tables in an existing database

Hi All,

I am writing this blog post to show how to migrate or move the standard MVC authentication tables into your existing database in your asp.net web application.

Background
When you create a MVC web application in VS 2013, VS embed a sql server database in your project, and this project is being used as a source of asp.net membership. Since you will not use this database as an embedded file and you want to have it as part of your existing database in SQL Server instance. The file is created under App_Data folder. To see the .mdf file click on Show all files in the solution explorer.
You can see the contents of this database and all tables in the server explorer window.

How to create those tables in SQL server ?

First, you can delete the .mdf file in App_Data folder. Since we don't need any of these tables.Then, we need to update the default connection string in the web.config to point to our database.

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=SERVER\INSTANCENAME;Initial Catalog=DBNAME;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>


Third, Open Nuget Package Manager and write the following commands:

Enable-Migrations
Add-Migration Init
Update-Database

Check out your database, all ASP.NET membership tables with Prefix Asp have been create and then you can test it out by running your application and execute membership actions such as Signing up or Signing in to your application.

Created tables after running above commands:
AspNetRoles
AspNetUserClaims
AspNetUserLogins
AspNetUserRoles
AspNetUsers
__MigrationHistory


Hope this helps.

Thanks

-- ME

Tuesday, June 10, 2014

Getting started with Solr for .NET architects & developers - part 1

Hi folks,

I am writing this blog post to provide some tips and insights on using open source search technologies such as Solr in your solutions and applications.

Here are my notes:
1) Solr is an open source search server product. It is free and one of the most trusted, mature search products in the market.

2) Solr uses lucene, lucene is the heart of Solr search server product. Lucene is the full text service or component that is used in Solr which provides all search, index and queries capabilities.

3) Lucene is a java based library to create, manage, and retrieve inverted index files.

4) Inverted index is a specialized data structure by Lucene to handle queries to text based documents.

5) Using full text feature that is available in some DBMS is not a replacement for Solr, Solr provides advanced search, query and ranking capabilities.

6) Solr provides on top of lucene full text capability the following features: pagination, sorting, faceting, auto-suggest, spell checker, hit highlighting, data modeling, grouping, and standard http API to integrate with your solutions.

7) Each Solt server has only one home, the path of the home is $SolrInstallation/example/solr, where $SolrInstallation is the path where you installed solr binaries.

8) Each Solr server can contain more than 1 core, each core contains its index data and configuration.

9) Solr web application is stored under solr.web folder which contains all servelts, html and js files.

10) Solr is running on Jetty as an application server. Google is using Jetty in its App Engine platform.


Hope this helps.

References: Solr in Action



Friday, April 25, 2014

Unable to retrieve metadata for unrecognized element 'providers' when adding a controller in VS 2013

Hi,

I was trying to add a new controller in my project using Visual Studio 2013. I was using Code First Entity Framework for my data access. I tried to build and clean the project few times before adding the new controller; but still was getting this error message when  adding a new controller to my web api project.

Here is the error message:


The solution is the following:
1) Open the web.config file in your project.
2) Scroll down until you see entity framework section.
3) This is how it will be looking:

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>

4) Remove the providers section.
5) Save and you will be able to add new controllers!

Hope this helps!


Thursday, April 17, 2014

Error when running web applications that reference SharePoint dlls in IIS Express

Hi All,

I was developing a web application that reference SharePoint 2013 dlls, and since SharePoint server dlls in general runs on a 64 bit environment, i want to use IIS express in Visual Studio 2013 without the need to use full local IIS that runs on 64 bit.

I was getting this error message when i am running my web application:

Could not load file or assembly or one of its dependencies. 

and i was seeing in the yellow error page that the VS 2013 is using IIS express under c:\ program files (86)\ IIS Express folder which is the 32 bit.


I want to switch IIS express to 64 bit so i will be able to run my web application that references 64 bit SharePoint dlls. here is the solution for this:

From Visual Studio 2013 IDE:

Click on :  Tools --> Options --> Projects and Solutions --> Web Projects  --> Use the 64 bit version of IIS Express --> check this checkbox and save.


Once you save, make sure you exit any instance of the IIS express and try to re-run your project! It will run with no issues!

Enjoy!


Tuesday, April 01, 2014

How to add a required field validator in SharePoint 2013 Application Pages using HTML5

Hi All,

I was developing a custom application page in SharePoint 2013, while adding all my controls in the custom application page i wanted to add a required field validator to a textbox control.

As a .NET developer, you will find the normal action is to add a required field validator to your page, which basically works, but in this post i want to show you that you can easily incorporate HTML5 validation attributes in SharePoint 2013 pages!!

In HTML5, you can add an attribute called required to any control, which tells the browser that this control is a required control.


<%@ Register TagPrefix="spuc" Namespace="Microsoft.SharePoint.WebControls"
             Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>


<spuc:InputFormTextBox ID="txtName" runat="server" class="ms-input"
      Title="Full Name" TextMode="SingleLine" Columns="40" required />


Adding a required attribute to your markup control will flag this control as a required control in your SharePoint page.

You can apply any other HTML5 validation attribute and it will render correctly in any SharePoint Page with no additional setup.

Here is a cool blog about how to apply HTML5 validation types into input control:
http://www.the-art-of-web.com/html/html5-form-validation/
 

Enjoy!



--ME

Working Tips with SPWebConfigModification Class in SharePoint 2013

Hi Folks,

I was working on updating a SharePoint web.config programmatically in SharePoint 2013 Farm Solution. Applying web.config modifications in SharePoint is straight forward task by adding the modifications into a collection of the web application and then submit your changes.

Since this class is poorly documented, I was trying to update a specific web application web.config and not all web.config in this farm. all the code samples in MSDN and other blogs don't provide a necessary understanding how it works so before taking the MSDN code and apply it into your feature or wsp you should know the following essential tips:

1) You can apply your web config modifications either on the web application level or the content service level which affects all web config files in your farm.

2) When your code has the following line of code, this means that the changes will be taken effect into all web applications in the farm:

SPWebApplication webApp = new SPSite('siteUrl').WebApplication;
WebApp.Farm.Services.GetValue<SPWebService>.ApplyWebConfigModifications();

Even though you are using a web application object, but this code will update all web.config files, which you should avoid when you apply solutions unless you are applying Farm updates.


3) If you want to update a specific web application web.config:

SPWebApplication webApp = new SPSite('siteUrl').WebApplication;
WebApp.Update();  // update specific web.config for this web application
webApp.WebService.ApplyWebConfigModifications();


line #3 will only update the web.config for a specific web application and not all unlike
SPWebService.ContentService.ApplyWebConfigModifications();

Hope this helps!

**References:
1) Add or remove entries in web.config programmatically:
http://msdn.microsoft.com/en-us/library/bb861909(v=office.14).aspx



Wednesday, March 12, 2014

Developer Dashboard doesn't show for anonymous users in SharePoint 2013

Hi All,

I was working on a public SharePoint site and i wanted to enabled the developer dashboard utility. I Ran the following powershell command to enable the developer dashboard:

Turn On Developer Dashboard Powershell Command:

$content = ([Microsoft.SharePoint.Administration.SPWebService]::ContentService)
$appsetting =$content.DeveloperDashboardSettings
$appsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::On
$appsetting.Update() 


**If you want to turn it off, just change the On flag to Off and you are good.

After that, I was able to see the developer dashboard icon in the Central Administration site but not on my public SharePoint site.

So basically, I found that you have to grant permissions for anonymous users to access this utility since it is not accessible for anonymous users even if the utility is enabled.

How to enable Developer Dashboard for anonymous users:

$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$dashboardSettings = $contentService.DeveloperDashboardSettings
$dashboardSettings.RequiredPermissions = [Microsoft.SharePoint.SPBasePermissions]::EmptyMask
$dashboardSettings.Update()


By default, the required permissions property for the developer dashboard utility is "AddAndCustomizePages" which is available for authenticated users who have this permission, so you need to changed it to no permissions by setting the value to EmptyMask which means in SharePoint permissions world no permissions are needed.

Note: This is a good technique while you are developing, testing and in the user acceptance test phase of any SharePoint implementation project. when you don't need this utility it is strongly recommended to turn it off on production environment.

Hope this helps!


References:
1) SharePoint base permissions:
http://msdn.microsoft.com/EN-US/library/ms412690






The memory usage on the current server is about {0}. This can cause the eviction or throttling of the Distributed Cache Service

Hi,

After enabling the usage and data collection service in SharePoint 2013, i was getting the following warning in windows event log:

The SharePoint Health Analyzer detected a condition requiring your attention.  The Current server is running low on memory.
The memory usage on the current server is about {0}. This can cause the eviction or throttling of the Distributed Cache Service/
Check the memory usage on the machine.And try to free up some memory or add more ram on the machine. For more information about this rule, see "http://go.microsoft.com/fwlink/?LinkID=224261".

How to tackle this memory consumption and performance issue in SharePoint 2013:

First, if in you are not utilizing the document activities, feeds or micro-blogging services in SharePoint so it is recommended to stop the Distributed Cache Service. this will give you a great performance boost in your box.

To get an understanding of the benefits of Distributed Cache Service in SharePoint read this TechNet post- Section "Benefits of Distributed Cache":

http://technet.microsoft.com/library/jj219700(office.15).aspx

Second, you can minimize the number of days you want to store SharePoint logs on the disk to free up some space. here is the steps:
1) Open Central Administration,
2) Click on Monitoring.
3) Under Reporting, Click on Configure diagnostic logging.
4) Scroll down to Trace log, where you can change the number of days to store log files from 14 to 5 days or you can specify the size of the log files in GB which gives you control over the size of these growing files.

Hope this helps.



Wednesday, February 19, 2014

RegisterSod is undefined

Hi folks,

I ran into an issue when i was working on a SharePoint hosted app, when the application loads it keeps throwing errors in the IE development tool that "RegisterSod is undefined".

I was deploying the application to the following site url:

http://SP2013/sites/appCatalog

The cause of this problem is that i didn't have a site in the root site collection, so i opened the Central Administration and created a site collection for the same web application that i am using to deploy my SharePoint apps to "appCatalog" site.

Re-deployed my application! it works!

Hope this helps!

-- ME

SharePoint Hosted App keeps prompting the username and password in SharePoint 2013

Hi All,

I was deploying a SharePoint Hosted App on my on-premise SharePoint 2013 Development VM and i was getting the Windows login window and it keeps prompting the username and password, then after 3 times the page goes blank with no errors or content in the default page.

After searching and trying different things, the fix wasn't not just to disable the loopback check in the registry that i had already as a DWORD 64 bit entry that is required to Crawl external SharePoint public websites.

The fix was to delete the DWORD 64 bit and replace it with 32 bit and the application starts instantiate with no issues and it starts working!.

Hope this tip helps.

Enjoy SharePointing!!


Monday, February 10, 2014

How to get the url for a SharePoint EndPoint hosted in a Service Application

Hi All,

This blog post is for SharePoint exposed EndPoints through Service Applications. If you are developing or deploying a custom Service Application in SharePoint 2010/2013 and you are exposing a WCF EndPoint Service EndPoint through the service application this blog post is helping you how to identify and get the Url for the exposed WCF EndPoint.

You need to test and make sure that the service application is working properly before checking any client application or webpart code that is consuming or integrating with this endpoint. Specially, if your endpoint might be having issues related to assembly dependencies or missing files that causes the service application to throw exceptions when it is being called from the client applications.

When you develop a service application in VS 2012/2013, the service application creates an application pool in the IIS, since you give it a name when you install it, and this expose a service instance where you can access it through a url!

To develop Service application for SharePoint 2010/2013, I strongly recommend this starter kit since it gives you a lot of ground work is done for you and you just need to code your logic in it.

http://chocolatey.org/packages/sastarterkitvs2012

Great shout out to Adam Toth !

So the question that needs an answer is:

What is the Url for the exposed WCF end point service that is hosted in a SharePoint Service Application?

1) You need to know the Service Application GUID that is installed in your farm, to do this Open SharePoint PowerShell and write below cmdlet:

Get-SPServiceApplication | select id,name

This will list all deployed service applications and provides the Service Application GUIDs.



2) Open IIS Manager, Expand SharePoint Web Services.
3) Look for the GUID that is associated with your service application.
4) Select the your endpoint and click on the browse from the IIS manager right pane.
5) Add the endpoint name "WcfEndPoint.svc" to the url !

http://localhost:32843/c20d8cbe444f4334a212ccba687dfbd7/MYWCFEndPoint.svc

Enjoy!









Monday, February 03, 2014

Web Part or Web Form Control on this Page cannot be displayed or imported. while adding a custom webpart in SharePoint 2013

Hi All,

I was developing a custom SharePoint web part for SharePoint 2013 using VS 2013, after i deployed the wsp and when i was adding the web part, i was getting the following error message:

Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe.


This is a common SharePoint error when you try to load custom user controls (or Visual Web Parts) into a SharePoint page. 

Any custom control has to be added as a safe control in SharePoint, before VS 2013 we used to add entries in the site web.config or code to add the safe control either programmatically to the site. but you do not need to do this in Visual Studio 2013 since it has a tool to add safe controls through a UI by specifying the namespace and the type and your control will be loaded with no issues or errors.

In VS 2013, follow these steps:

1) Double click on the package item.
2) Under Advanced tab.
3) If the custom control exists in an assembly so when you add the assembly that contains your user control click on add safe control button and specify your assembly & type for their user control.
Or even if the custom control is contained in a project within your solution, so when you add the project output in the package explorer UI, you can still add the user control as a safe control by specifying the namespace and type fields.

4) Safe the changes, build and deploy.
5) Refresh the SharePoint page.
6) Add your custom web part and you will not get the error message.

Enjoy!


Transform XML using XSLT document to HTML output in IE

Hi All,

I was developing a JavaScript function that takes an xml document for a HTTP response and i want to transform it to HTML in my page or web part (in SharePoint world).

I had code that uses transformNode that is not supported by IE anymore starting from version 9 and i am using IE 11.

Actually, i spend a quite number of hours to find out what is the best way to load an XML document and transform it using a XSLT file into a HTML output in IE 11 since i was getting different errors.

You will find a lot of posts/blogs are referring to this code snippet to transform xml using xslt file in IE:

var xml = new ActiveXObject("Microsoft.XMLDOM"); 
var xslt = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
xml.load("data.xml");
xslt.load("data.xls");

var processor   = new ActiveXObject("Msxml2.XSLTemplate");
processor.stylesheet = xslt;

var objXSLTProc = processor.createProcessor();
objXSLTProc.input = xml;
objXSLTProc.transform();
var output  = objXSLTProc.output;

Above code doesn't work in IE 11, for 2 reasons:
1) IE 11 doesn't support load method! you have to use loadXML instead.
2) you have to get the string representations of both xml and xslt to be able to use loadXML and then process the output.

Here is the code snippet that works with IE 11:

function transformXml(xml)
{

var loadedXslt = LoadXSLTDocumentInIE("myxslt.xslt");

  // Load the XML Document
  var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
  xmlDoc.async = false;
  xmlDoc.resolveExternals = false;
  xmlDoc.loadXML((new XMLSerializer()).serializeToString(xml));
   console.log(xmlDoc.parseError.reason); // for debugging, to make sure there is no errors after loading the document.

    // Load the XSL file
    var xslt = new ActiveXObject("Msxml2.XSLTemplate");
    var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
    xslDoc.async = false;
    xslDoc.loadXML(loadedXslt.responseText);
    xslt.stylesheet = xslDoc;

    var xslProc = xslt.createProcessor();
    xslProc.input = xmlDoc;
    xslProc.transform();
    return xslProc.output;

}

// function to load XSLT document by name, this document has to be accessible through the web browser.
function loadXSLTDocumentInIE(fileName) {
   xhttp = new ActiveXObject("Microsoft.XMLHTTP");
   try {
        xhttp.responseType = "msxml-document";
    } catch (e) {
        //console.log("couldn't set the response type msxml in IE");
    }
    xhttp.open("GET", fileName, false);
    xhttp.send("");
    return xhttp;
}


This code works like a champ in IE 11 :)

Hope this helps.





Tuesday, January 21, 2014

How to get the Query String value in SharePoint 2013 Search Results page

Hi All,

I was working to customize the search results web part by customizing the Search Result Display Item template and the Item Hover Panel as well.
If you want to read more about how to customize the search display templates read below blog post:
http://moustafa-arafa.blogspot.com/2014/01/customize-sharepoint-2013-search.html

I was trying to get a value of the query string that SharePoint 2013 passes once you hit enter in the Search Box, and since this control doesn't have an ID, I decided to pull the value from the query string that has a key "K".

After i developed this scenario, I found that SharePoint if you ran another search keyword for the second time, It would append the newer keyword with anchor (#) and will keep the old search keyword in the query string with key "K"

For example, When you run the search for the first time with keyword "copyright":

http://myPortal2013/sites/sp2013/search/pages/results.aspx?k=copyright

If you changed the search keyword to "digital", here is the new url would be:

http://myPortal2013/sites/sp2013/search/pages/results.aspx?k=copyright#digital

In my case, i want to get the "digital" and not "copyright" keyword so i want to parse the Url and get the latest search keyword. Here is the code to accomplish this:


This code i wrote it in the outer div element of the body of your display template html file.

Note: You can use this variable "sParam" as you like in the Display Template html file.

Hope this helps.

-- ME

Customize SharePoint 2013 Search Display Templates

Hi Folks,

In this post i will show how to customize SharePoint 2013 Display Templates and specifically the Search Templates.

In SharePoint 2013, you can customize the search results web part by editing the configuration of the web part. but if you want to customize the rendered output/layout in this case you need to use SharePoint Designer 2013 or any HTML editor to customize the search result item or the hover panel.

How to customize the search result item in Search Results web part:

1) From Site Settings page, Click on Master Pages and Page Layouts.
2) Click on Display Templates, This folder contains all SharePoint 2013 Display Templates.
3) You will find wide range of folders under Display Templates, Since we need to customize the search display template, click on Search Folder.
4) You need to find 2 items in this list, here are these files we need to download a copy of them:
     Item_Default.html
     Item_Default_HoverPanel.html
5) Select these 2 files and download a copy of them. DO NOT SELECT THE .JS files with the same name. We do not need them, they will be created for us!




6) Once you select both files, click on any little arrow beside the file title and click on Download a copy.
7) Copy these file and rename them so this will be your customized template to be associated with the search results web parts.

For example: let us call them: Item_Default_Custom.html , Item_Default_HoverPanel_Custom.html

7) Upload both files to the list, you will notice a .js file is created for each of the files.
8) Now, we have our own custom template that we can customize in SharePoint.
9) Open SharePoint Designer 2013, From All Files --> _ catalogs  --> masterpage --> Display Templates --> Search
10) You will find both files we just uploaded, here is it is up to you. If you want to customize the search result item, then we will open Item_Default_Custom.html.
If we want to customize the Hover panel when you hover on a search result item, then we have to open Item_Default_HoverPanel_Custom.html.

Tip: In all cases, you should not modify the .js version of the html files. The Javascript file is a SharePoint file that is being updated/generated every time you save any change in the html files.

The changes in the search html template, it requires standard web development experience for editing html and writing javascript code.

Below is a very useful blog, It shows some techniques in how to customize the html files and embed some javascript code If you are not familiar with SharePoint/Web development.

http://sharepointfieldnotes.blogspot.com/2012/11/customizing-sharepoint-2013-search.html


How to configure Search Results Web Part to load your custom Display Template:

Once you customize the search display template, One last step is to configure the Search Results web part to load your template, Below is how to do it:

Your custom Search Display Result item will be loaded in the Display Templates in the web part configuration and once you select it, any change you do in the html will be reflected once you refresh the page in SharePoint 2013.



Hope this helps.



Friday, January 10, 2014

Error when creating search center site in SharePoint 2013

Hi folks,

I was trying to create an enterprise search center site in my SharePoint 2013 VM. When i was clicked on Create button i was getting the well known yellow error page in SharePoint.




I straight up checked the logs and i found the following error message:

Exception in EnsureFeatureActivatedAtWeb: Microsoft.SharePoint.SPException: The SharePoint Publishing Infrastructure feature must be activated at the site collection level before the publishing feature can be activated.

So,  I went to the site settings  --> site collection features --> then i activated the SharePoint Publishing infrastructure feature.

Then, I went back to create a subsite --> selected enterprise search center. I entered all required information and when i clicked on create. the site is created with no errors!

Monday, December 16, 2013

Platform Not supported Exception when running Visual Studio Web Application

Hi All,

While i was developing a web application that creates an instance of a custom service application using Visual Studio 2013, I was getting this error:

Exception Type: PlatformNotSupportedException

Details:

Microsoft SharePoint is not supported in 32-bit process. Please verify that you are running in a 64-bit executable.


I have another SharePoint web part project that connects with no issues to the SharePoint custom service app, but this web application is throwing this exception! so, the error is related to the IIS express which is the default IIS for VS 2013 web projects.

The error will exist or be thrown when you create any SharePoint object such as: SPSite to connect and then implement your logic.

I googled little bit and i found that some blogs were saying to un check the prefer 23 bit under Build tab in the project properties, In my case this check is grayed out so i don't have the option to un check it.

In addition to that, by default all SharePoint projects or Web Projects are targeting AnyCPU, so you shouldn't change this specially if you are connecting or integrating with SharePoint.


The fix:
1) Right click on the web project that you are having this error and click on the web tab.
2) Under Servers, change the selection from IIS express to Local IIS, This will use the local IIS instance which is a 64 bit installation of your SharePoint Development machine.
- Note: This will allow VS 2013 to create a virtual directory and attach the process, so you will be able to debug once you hit F5.
3) Run you project, the code works with no exception when creating any SharePoint object such as a Site or Web...etc.

SharePoint Development Machine Configuration: Win Server 2008 R2 64 bit, VS 2013 latest release.

Happy SharePointg!!

Tuesday, December 03, 2013

Sorry, Something went wrong when deploying WCF service in SharePoint 2013

Hi,

While i was developing a RESTful WCF Service that is targeting SharePoint 2013 using VS 2013, I was getting the following "White" error page when i access the WCF service after deploying my project in VS 2013.




As shows in the above screen shot, The error is related to getting and loading the right assembly for my WCF service class type, I know the GUID in my WCF class is matching the GUID in the svc file. But what is the problem ?

I found out that the solution for this problem is SharePoint doesn't accept the upper case letters in the GUID.

This was my GUID:  CDCC536B-37BB-4CC3-BF20-263AB66926D5

I changed the GUID by replacing the upper case characters to lower case characters in the Service class and in the SVC file, then save and deploy! It works!

Happy SharePointing!


Sunday, December 01, 2013

HTTP 500 error when you login in Joomla as an administrator

Hi All,

I was trying to install and configure one of the most popular open source CMS Joomla 3.2. After i installed and configured my first site, I was getting HTTP 500 error when i log in as administrator from the site.

I checked and i found that the super user is created in the database and the username/password has permissions to access the created DB for the site but i can not log in to the CMS site as a super user or administrator!

I check the configuration.php and web.config and i found the following http handlers has been added in the web.config file by IIS.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="true" />
        <handlers accessPolicy="Read, Execute, Script">
            <remove name="PHP55_via_FastCGI" />
            <add name="PHP55_via_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.5\php-cgi.exe" resourceType="Either" requireAccess="Script" />
        </handlers>
    </system.webServer>
</configuration>


I have installed and configured PHP 5.5 using IIS 7.5 in Windows 8 but i do not know why the IIS has added the highlighted entries in the web.config.

The fix, is to remove the PHP http handlers from the web.config and the log in will start working like a charm !

Hope this helps.
- ME

Thursday, November 14, 2013

Where is Microsoft.SharePoint.ApplicationPages.Administration.dll in SharePoint 2013

Hi,

If you are developing custom application pages in SharePoint Central Administration, you will be in need to add this reference in your project, Here is the path for this dll:

c:\program files\common files\microsoft shared\web server extensions\15\CONFIG\ADMINBIN

Enjoy!

Monday, November 04, 2013

You do not have the necessary permissions to change the domain logon for this user

Hi,

While i was importing a Microsoft Dynamics CRM 2011 solution i was getting this error message:

"You do not have the necessary permissions to change the domain logon for this user"


The Service account that is running the CRM Server App pool is a member of the Administrator group, and a member of deployment administrators group. So what is missing ?

It turned into that the service account does not have the permissions to a certain folder that is being used by MS CRM Server 2011 for imported solutions, here is the folder path:

c:\program files\ Microsoft Dynamics CRM\CustomizationImport

Add the service account to have full access to this folder and then you will be able to import your custom solution in CRM.

Hope this help.

Thursday, October 31, 2013

Exit Code: 5100 while installing CRM 2011

Hi,

While i was installing a MS CRM 2011 on a Windows Server 2008 R2 VM, the installation was hanging or taking forever after i accept the license agreement. checked the logs and this is what i found:


Since my Machine did have SQL 2012 and VS 2013 so VC++ 10 x86 & x64 were installed on my machine and that was the reason for the hanging issue while the installer is trying to install these components on my machine.

Some blogs will be saying the following and this is WRONG because it will break your SQL 2012 installation and you will not be able to open SQL Server 2012 or continue your CRM 2011 installation because you don't have a running instance of SQL server.

DO NOT DO THIS : "Un install all VC++ components from your machine and then re-run the installer, you will notice it wouldn't take a second to move from the license agreement page to the prerequisites form next."

The solution is to have an updated installer from Microsoft to fix this glitch when you have a VM with SQL 2012 pre-installed on it and it contains VC++ components installed.

KB about this issue: http://support.microsoft.com/kb/2686619/en-us

Get an updated installer from the below link:
http://www.microsoft.com/en-us/download/details.aspx?id=27822


Hope this helps.

Friday, October 18, 2013

Tips and Tricks on NuGet Packaging for .NET Developers

Hi,

Recently i have the chance to work NuGet, NuGet is an open source Packaging Server and set of tools that you can use to package your work within an organization for distribution or publicly upload your packages to nuget.org to be utilized by all developers.

First, You need to create a website to be accessible by all developers, and then upload or install NuGet server package to it. NuGet Server at the end of the day is a website that holds all your packages.

To host your NuGet Packages in a server:

1) Open your VS 2012 or 2013 and then create an empty web application.
2) Open the Package Console window and install-Package NuGet.Server, this command will install all server components.
3) By Default, you can once you know how to create nuget packages, you need to push it to the packages folder that will be created for your once you install the NuGet Server packages.
4) There are some cool features once you open the web.config, such as the key you need to publish nuget packages.
5) Basically, that's all from the server perspective.

Second, you need to know how to author or design nuget packages, what you need to do, install the Nuget Package Explorer from this url: http://npe.codeplex.com/

Once you install this ClickOnce Windows Application, you will be able to create, design and deploy nuget to the server we just mentioned earlier.

Some tips to create nuget packages using NuGet Package Explorer:
1) You have to set all your dlls in the lib folder, since all these dlls will be added to the references once you install the package.
2) To add the lib folder to your package, right click on the right pane and then select lib folder.
3) You can add dlls to your lib folder by dragging and dropping the dlls to the lib folder in the right pane.
4) You can set any content under content folder such as: images or any required files are needed for any application to utilize your nuget packages.

5) Under lib folder you can different target .NET frameworks such as: .NET 4.0, .NET 4.5



6) The nuget is referring to the target .NET frameworks as follows: net40 to refer to .NET 4.0 and net45 referring to .NET 4.5.
7) Once you save all your referencing dlls, content and .net & nuget packages dependencies, you just need to save the nuget file and then from the file menu item publish to the nuget server.
8) You can even add powershell files when you install, un install and when every time you open VS project which is the purpose of init.ps1.



NuGet Documentation: http://docs.nuget.org/

Hope this helps, let me know if you have any questions.


Wednesday, October 02, 2013

Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions when deploying a WCF on Windows Azure

Hi,

I was deploying a WCF service on windows azure, after deploying it and then when i was trying to connect to the end point i was getting this exception:


System.Configuration.ConfigurationErrorsException: Configuration binding extension 'system.serviceModel/bindings/basicHttpsBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.

I thought it is something related to some missing configuration that i need to do on Azure even though the WCF is working fine on my development box. It turned to something simple you need to add on your web.config and it fixed the issue.

Add targetFramework="4.5" to the httpRuntime element in your web.config


Refresh the WCF end point page, you will be able to access and see the WSDL file for your WCF.

enjoy!

Sunday, September 29, 2013

Principal User is missing prvReadSolution privilege in CRM 2011 using VS 2012

Hi,

I was working with the latest CRM 2011 SDK using VS 2012 and when i was creating a workflow for MS Dynamics CRM, i got an error while trying to connect to the CRM. Here is the error message:



Principal User is missing prvReadSolution privilege


To fix the problem, follow below steps:
1) Login to your CRM.
2) Select Settings tab.
3) Click on Administration and then click on the Security Roles icon, or if you assigned the permissions to the user directly then open the permissions tab for the user you are using to login to the CRM from VS 2012.
4) Click on the customization tab.
5) Look for the solution list item and set the read permissions only.



6) Click on Save and Close.
7) Try to connect from VS 2012, you will be able to connect with no issues.

Hope this helps.

Sunday, September 15, 2013

One or more errors occurred while processing template 'Entity.tt'. Using Reverse Engineer Code First in VS 2012 Update 1

Hi,

Using VS 2012 Update 1, I was doing some changes in my database schema and when i try to reverse engineer code first my updates i was getting the following error:

One or more errors occurred while processing template 'Entity.tt'.

In the output window, VS listed that System.Xml and System.Xml.Linq exist on 2 different paths, one where the .NET framework is installed and the other one is pointing to the Siliverlight 5 DLLs in the GAC.

While it is reported as a bug in Microsoft Connect website, I was trying to remove the link to the Silverlight 5 Dlls that i'm not in need when i reverse engineer code first my EF files to apply my DB changes.

To fix this problem: 
1) Open the following directory:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes

2) Take a backup from EF.Utility.CS.ttinclude or the VB version based on the your project language you are using.

3) Open the notepad in an administrator mode.

4) Open the CS.ttinclude file.

5) change the following 2 lines:

<#@ assembly name="System.Xml" #>
Change it to:
<#@ assembly name="System.Xml, Version 4.0.0.0, Culture=neutral" #>

<#@ assembly name="System.Xml.Linq"#>
Change it to:
<#@ assembly name="System.Xml.Linq, Version 4.0.0.0, Culture=neutral"#>

6) Save the file.

7) Right click on the project that has the EF files and click on Reverse engineer Code First.

8) bingo! you will get your database updates with no errors.


Let me know if you have any issues with this.

Thursday, September 12, 2013

Tips on SharePoint 2013 Branding and UX Design

Hi All,

I had the opportunity to work with SharePoint 2013 Branding and building new UX related components such as: Master Pages, Page Layouts and Content Types development on a SharePoint 365 site or SharePoint 2013.

I found some interesting tips and tricks and i'd like to combine them all in this blog post for End Users, Designers, Architects and anyone who works in SP branding and customization.

Here are some general information and tips to know ahead before getting in creating new UX SharePoint components:

1) If you are new to SharePoint and you want to understand how MasterPages are connected to page layouts and actual pages, I recommend reading this article first:
http://msdn.microsoft.com/en-us/library/jj191506.aspx

2) In SharePoint 2013, You can create your master page in any html editor --> sweet!
3) Once you are signed off on the new look and feel of the new master page in HTML, A good option: you can map the new master page in html with all related javascript and CSS files to the SharePoint Master page gallery, Here is how to do it:
http://msdn.microsoft.com/en-us/library/jj733519.aspx

4) Another option is: you can directly convert the html master page to an actual master page; where SharePoint will create a new file with .master extension and add SharePoint attributes and place holders used by SharePoint, here are the steps using the design manager:
http://msdn.microsoft.com/en-us/library/jj822370.aspx

5) Design Manager is a new feature in the publishing sites, you can use it to brand public facing SharePoint sites and Office 365 sites. Read an overview about How to use Design Manager in SharePoint 2013:
http://msdn.microsoft.com/en-us/library/jj822363.aspx

6) Once you create your new master page, you might need to create new set of page layouts that provide nicer UX to your visitors, This article shows how to create new page layouts in SharePoint 2013 and office 365:
http://msdn.microsoft.com/en-us/library/jj822368.aspx

7) If you want to have different UX for Mobile and tablet users, you should create different channels aka different master pages and page layouts for different targeted devices, this article describes how to implement this in your site:
http://msdn.microsoft.com/en-us/library/jj862343.aspx


Hope this helps, drop me a line if you have any questions or clarifications.



Reference:
- Build Sites for SharePoint 2013:
http://msdn.microsoft.com/en-us/library/jj163242.aspx


Monday, August 05, 2013

SharePoint 2013 Strategy client object model (CSOM) tips


Hi Folks,


I have consolidated some useful tips about CSOM in SharePoint 2013 from training vidoes i found on MSDN and i decided to put it on a blog post so it is easier and faster to get your notes out of them.


1)      In SharePoint 2010, you can’t access client.svc to conduct client calls to SharePoint Object model, instead you use .NET, Silverlight, or JavaScript client library to conduct client call to the WCF client.svc on the server from your client applications.

2)      In SharePoint 2013, you can directly access client.svc from REST clients.

3)      In SharePoint 2013, Client.svc accepts HTTP verbs such as: GET, POST , PUT.

4)      Extended CSOM API that supports more functionality such as: Search, Taxonomy, Publishing, Analytics, Workflow and E-Discovery.

5)      “_api” is a new alias for “_vti_bin/client.svc” to access the end point.

6)      CSOM code in SharePoint 2010 should be migrated to SharePoint 2013 CSOM with no issues.

7)      ListData.svc still available for backward compatibility applications from SharePoint 2010 into SharePoint 2013.

8)      It is not recommended to use ListData.svc in your SharePoint 2013 CSOM code, Use OData API instead, check #12.

9)      You can use fiddler to monitor client queries in CSOM code, especially when you call ExecuteQuery() in CSOM code.

10)   Using IE developer tool and Fiddler are essential when you code using JavaScript to call sp.js in CSOM. It also allows seeing the details of the request and JSON response content.

11)   FormDigest is being created the first time when calling ExecuteQuery for the first time; this is being used on all consecutive calls.

12)   Simply OData URIs as follows to access the web:


Simplified: http://www.contoso.com/_api/web

To access “Announcements” list:


Hope this notes would help.




Reference:
SharePoint 2013 CSOM and OData API Training Videos
 

Tuesday, July 23, 2013

Fix It: 3 steps to show your SSRS report header in all pages while scrolling

Hi Folks,

I'm writing this blog about a tip i spent some time to fix in one of my SSRS reports. The issue is that i have my header is visible while i'm scrolling but only in the first page. I want the header to show in all report pages and not just the first page.

I didn't find a resource or MSDN article to resolve this issue but i tried the old technique "try and error" until i found a resolution for it and then i have my header is showing while i'm scrolling in all my report pages.

The case:
You have a tablix in your report with header, you want to keep the header visible while scrolling in all pages.

The solution is in 3 steps:

1) Set "FixedData" property for each header column to True.  Here is how to do it:
     http://msdn.microsoft.com/en-us/library/dd220509.aspx

2) Now, If you previewed the report, you would see the header is visible while scrolling!!, here comes the trick, Select the (Static) item from the Row Groups right pane and open the properties window.



3) Set the following properties to True:
   Set FixedData, RepeatOnNewPage properties to True
   Set KeepWithGroup property to After

Now, Preview your report from VS 2012 SSDT or BIDS and you will see that you have visible column in all report pages!

Enjoy!
 

Wednesday, July 17, 2013

What’s new in Records Management and Compliance in SharePoint 2013


Hi Folks,
I’m writing this article about what’s new in Records Management and Compliance in SharePoint 2013. SharePoint 2013 has extended the retention policies to be applied on the site level!.

Having the site retention policies on the site level is a cool feature, especially for most of the small/medium organizations that creates sites for their departments and not site collections.

Another cool feature which is the site policy also applies on SharePoint 2013 Foundation, so you can apply your site retention polices if you have SP 2012 Foundation instance.

Site Level Retention:

You can manage retention policies to SP sites and exchange 2013 team mailboxes that are associated with the sites.

Compliance officers create policies, which define the following:

n  The retention policy for the site and the associated exchange team mailbox, if any is associated.

n  What causes the project to be closed?

n  When a project should expire.

Here are the steps to apply compliance and retention policies:

1)      The site owner creates a SharePoint site.

2)      The site owner creates an exchange server 2013 team mailbox.

3)      The site owner assigns/selects the appropriate retention policy template.

4)      The site owner invites team members to join the site.

5)      All emails and documents among the site team members, the selected policy will be applied.

6)      When the project is completed, the site owner closes the project.

7)      Once the project is closed by the site owner, all project folders in outlook 2013 User Interface will be removed.

8)      When the project expires as per the selected policy, all associated artifacts to this project will be deleted.

 Hope this helps.

Useful Urls:

** Overview of site permissions in SharePoint 2013