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.