Musings on Cloud, BigData, AI, Machine Learning, Containers and IOT

How SharePoint 2010 customizations can be mapped to SP 2013 App Model

I tried to do a mapping on how the SharePoint 2010 server-side customization can be mapped to SP 2013 App Model, here is the list below.

No SP 2010 Farm Solution SP 2013 App Model
1

Alternate CSS in hive

Apps cannot deploy files to SharePoint’s root files/hive. Instead, css can be deployed to SharePoint using a module or app installed event

2

Alternate CSS in Module

Apps cannot deploy files to SharePoint’s root files/hive. Instead, css can be deployed to SharePoint using a module or app installed event

3 Application Page

Apps cannot deploy files to SharePoint’s root files/hive, which includes the layouts folder. As an alternative, web part pages can be deployed through a module or app installed event receiver

4 Custom Column

Declarative columns can only be deployed to the app web. To deploy columns to Host Web leverage App Installed Event

5 Content Type

Declarative content types can only be deployed to the app web. To deploy content types to App Web leverage App Installed Event

6 Custom Action Apps support specific types of custom actions, including ribbon commands and context menus in both the app web and host web.
7 Delegate Control

Apps for SharePoint do not support delegate controls. Add custom HTML snippet to the Master Page to achieve the effect of delegate controls

8 Feature Receiver

Apps have remote events for “App Installed”, “App Uninstalling”, and “App Upgraded”. All of these can be used in a similar way to feature receivers in farm solutions.

9 Feature Stapling

Apps can be “stapled” through the app catalog, leverage the concept of App Stapling

10 Images (in hive)

Apps cannot deploy files to SharePoint’s root files/hive. Instead, images can be deployed to SharePoint using a module or app installed event

11 List definition

Apps can deploy custom list definitions, but only to the app web and not the host web

12 List Event Receiver

Leverage Remote Event Receivers to address on-premise List Event Receivers for Cloud

13 List Instance

Declarative list instances can only be deployed to the app web and not the host web. `

14

Master Page (in hive)

Apps cannot deploy files to SharePoint’s root files/hive. Instead, master pages can be deployed to SharePoint using a module or app installed event
15

Master Page (Module)

Apps can use modules to deploy master pages to SharePoint, but only to the app web…not the host web. Leverage app installed event can be used to deploy a master page to a host web

16 Module

Apps can leverage modules to declaratively deploy files into SharePoint

17

Script (in hive)

Apps cannot deploy files to SharePoint’s root files/hive. Instead, script can be deployed to SharePoint using a module or app installed event

18 Search Configuration Apps for SharePoint can be used to consistently and efficiently deploy a search configuration to a number of sites
19 Site Definition

Site definitions deploy files into SharePoint’s root files/hive, which is not a capability of apps for SharePoint

20 Timer Jobs

Timer Jobs cannot be addressed in App Model

21

User Controls (Control Templates

Apps cannot deploy user controls to SharePoint hive, consider other alternatives

24 Webpart Apps can deploy App Parts to SharePoint
25 Web Part Page Leverage App Installed event to provision a web part page to the Host Web. However for App Web, leverage Modules.
26 Web Template Web Templates can be installed to the host web’s site collection root using the App Installed event
27 Workflow Workflow is supported in SP 2013 App Model
28 Workflow Activity Workflow activity is supported in SP 2013 App Model

 Subscribe to my blog

InfoPath Publishing error – The following url is not valid

I was involved in a SharePoint 2013 On-Premise Platform setup. After our successful installation we faced an issue as stated below.

Issue:

We were not able to publish any InfoPath form to  SharePoint site created in the 2013 environment, in spite of the site being accessible from the browser. When we try to publish the form we get the following error “The following url is not valid”. This is a quite common and annoying error message that you get when it comes to InfoPath publishing.

clip_image001

We got a HTTP 404 error when we analyzed the fiddler trace, while the InfoPath form is published to SharePoint.

clip_image002

Options attempted for Fix

After referring so many blogs, I patiently tried the following steps to fix this problem. But nothing worked.

• Checked if it has a root site collection. (Make sure the SharePoint application that contains the site you are publishing to, has a site in the root)

• Stopped the “System Event Notification” service

• Added the verb entry in the http Handler tag (Make sure that the <remove verb=”*” path=”*.asmx”/> is just under <httpHandlers> tag)

• Added a host entry for the URL and restarted the server

• Delete all sub keys of “Server Cache” key, they are in form of _http://xxxxxxx

• This seems to be the problem when your site is on a non-default port, Switched to port 80, still same error.

Resolution:

Upon troubleshooting this issue i found that InfoPath client was not able to find the root (/) site collection and it threw a HTTP 404 error in Fiddler.  We had to add the HTTP verbs (GET, POST, PUT, HEAD, etc.) explicitly in our IIS Server -> request filtering module which solved the particular issue that I was facing

After adding the verbs, verify the new verbs are in config file C:WindowsSystem32inetsrvconfigapplicationHost.config.

Verbs will be under /configuration/system.webServer/security/request Filtering/verbs section.

In a nutshell the PUT request to the site was failing, for which i had to add the verbs.

 Subscribe to my blog

How to publish a post to the Office 365 SharePoint 2013 Social Feed using Client Object Model (CSOM)

In this article, I’ll explain on how to post to Office 365 SharePoint Social Feed using .NET Client Object Model (CSOM).

Step1  Create a Console application by name ‘PublishToSocialFeed’

Step2 Add references to the following assemblies

Microsoft.SharePoint.Client
Microsoft.SharePoint.ClientRuntime
Microsoft.SharePoint.Client.UserProfiles

Step3 Add references to the following assemblies

using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Social
;

Step4

Create a Public Function by name ‘PublishPost’ and add the following snippet of code.

public static void PublishPost()
       {
           Uri oUri = new Uri(“
https://yoursite.sharepoint.com”);

           Office365ClaimsHelper claimsHelper = new Office365ClaimsHelper(oUri, “youruserid@yoursite.onmicrosoft.com”, “yourpassword”);
          
           using (ClientContext oClientContext = new ClientContext(oUri))
           {
               oClientContext.ExecutingWebRequest += claimsHelper.clientContext_ExecutingWebRequest;

               SocialFeedManager oSocialFeedManager = new SocialFeedManager(oClientContext);
              
               //Create an instance of Social Data Item object
               SocialDataItem oSocialDataItem = new SocialDataItem();
               oSocialDataItem.ItemType = SocialDataItemType.Link;
               oSocialDataItem.Text = “Google”;
               oSocialDataItem.Uri = “
http://google.com”;

               //Create an instance of Social Post Creation Data
               SocialPostCreationData oSocialPostCreationData = new SocialPostCreationData();
               oSocialPostCreationData.ContentText = “This is my first post”;

               oSocialFeedManager.CreatePost(null, oSocialPostCreationData);
               oClientContext.ExecuteQuery();

               Console.WriteLine(“Published a news feed”);
           }

       }
To know more about ‘Office 365 Helper’ class and active authentication for Office 365, please refer to Wictor Wilen’s article.

 Subscribe to my blog

How to retrieve list of installed Workflows in SharePoint 2013 Office 365 site using CSOM

In this article, I’d be articulating on how to retrieve list of installed workflows in SharePoint 2013 Office 365 site using Client Side Object Model (CSOM). Just to give a background the workflow framework in SP 2013 has undergone a major revamp, there are new WorkflowServicesManager and WorkflowDeploymentService objects, we’d also be leveraging the new APIs accordingly to retrieve

Create a console application and name it as ‘RetrieveInstalledWorkflows’.

Add references to the following dll’s.

Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll
Microsoft.SharePoint.Client.WorkflowServices.dll

Import the following namespaces

using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.WorkflowServices;
using Microsoft.SharePoint.Client.WorkflowServices;
using Microsoft.SharePoint.Client.Workflow;

Create a static method by name ‘RetrieveInstalledWorkflows’ and implement the following snippet of code.

public static void RetrieveInstalledWorkflows()
{
    Uri oUri = new Uri(“
https://yoursite.sharepoint.com”);
   
  
    Office365ClaimsHelper claimsHelper = new Office365ClaimsHelper(oUri, “userid@yoursiter.onmicrosoft.com”, “your password”);
    using (ClientContext oClientContext = new ClientContext(oUri))
    {      

        oClientContext.ExecutingWebRequest += claimsHelper.clientContext_ExecutingWebRequest;
       
        //Get the instance of Workflow Services Manager
        WorkflowServicesManager oWorkflowServicesManager = new WorkflowServicesManager(oClientContext,oClientContext.Web);

        //Hook to WorkflowDeploymentService
        WorkflowDeploymentService oWorkflowDeploymentService = oWorkflowServicesManager.GetWorkflowDeploymentService();

        //Fetch all the installed workflows
        var oWorkflowDefinitionCollection = oWorkflowDeploymentService.EnumerateDefinitions(true);
        oClientContext.Load(oWorkflowDefinitionCollection);

 
        oClientContext.ExecuteQuery();

        foreach(var oWorkflowDefinition in oWorkflowDefinitionCollection)
        {
            Console.WriteLine(“Workflow”+oWorkflowDefinition.DisplayName);
        }

        Console.ReadLine();

    }

}

To know more about Office365ClaimsHelper class, please refer to Wictor Wilen’s article on active authentication

 Subscribe to my blog

How to publish a post to SharePoint Social Feed using SharePoint 2013 JSOM

In this article, I’ll explain how to publish a Post to the SharePoint Social Feed using SharePoint 2013 JavaScript Object Model (JSOM).Open Visual Studio 2013, Create a new SharePoint Hosted App and name it as PublishPost.

Go to default.aspx, add a reference to SP.UserProfiles.js in the PlaceHolderAdditionalPageHead

<script type=”text/javascript” src=”/_layouts/15/sp.userprofiles.js”></script>

Add the following Javascript function in the App.JS file (comment out the existing code already in the file)

SP.SOD.executeOrDelayUntilScriptLoaded(WritePost, ‘SP.UserProfiles.js’);

function WritePost() {
    var oclientContext;
    var ofeedManager;
    var oresultThread;

    // Initialize the current client context and the SocialFeedManager instance.
    oclientContext = SP.ClientContext.get_current();
    ofeedManager = new SP.Social.SocialFeedManager(oclientContext);

    // Add a link to be included in the post.
    var olinkDataItem = new SP.Social.SocialDataItem();
    olinkDataItem.set_itemType(SP.Social.SocialDataItemType.link);
    olinkDataItem.set_text(‘My blog url’);
    olinkDataItem.set_uri(‘
http://sundarnarasiman.net’);
    var osocialDataItems = [ olinkDataItem ];

    // Set up the post content
    var opostCreationData = new SP.Social.SocialPostCreationData();
    opostCreationData.set_contentText(‘The text for the post, which contains a {0}.’);
    opostCreationData.set_contentItems(osocialDataItems);

    // Write the post
    oresultThread = ofeedManager.createPost(null, opostCreationData);
    oclientContext.executeQueryAsync(WriteSucceeded, WriteFailed);
}

function WriteSucceeded(sender, args) {
    $get(“ResultMessage”).innerText = ‘Successfully posted the message to Posts’;
}
function WriteFailed(sender, args) {
    $get(“ResultMessage”).innerText = ‘Failure in writing message’ + args.get_message();
}

Open the default.aspx and add the following snippet

<Div id=”ResultMessage” style=”color: blue”></Div>

Open the AppManifest.XML and provide FullControl permission to UserProfiles (Social) and Tenant. Otherwise, you’ll get a permission error.

<App xmlns=”http://schemas.microsoft.com/sharepoint/2012/app/manifest”
     Name=”PublishPost”
     ProductID=”{72faf665-bf93-4a8e-88a7-2d2ad0be0f9d}”
     Version=”1.0.0.0″
     SharePointMinVersion=”15.0.0.0″
>
  <Properties>
    <Title>PublishPost</Title>
    <StartPage>~appWebUrl/Pages/Default.aspx?{StandardTokens}</StartPage>
  </Properties>

  <AppPrincipal>
    <Internal />
  </AppPrincipal>
  <AppPermissionRequests>
    <AppPermissionRequest Scope=”
http://sharepoint/social/tenant” Right=”FullControl” />
    <AppPermissionRequest Scope=”
http://sharepoint/content/tenant” Right=”FullControl” />
  </AppPermissionRequests>
</App>

Now, you’ll see that the post being published to MySite.

social post

 Subscribe to my blog

How to read SharePoint 2013 User Profile using JSOM

In this article i ‘b be dealing with how to read SharePoint 2013 User Profile properties using Javascript Object Model (JSOM). We know that SharePoint 2013 provides JSOM support for User Profile properties.

Create a SharePoint Hosted App and call it as ‘Read User Profile’

Go to Default.aspx in the SP Hosted App and add the references to SP.UserProfile.Js in the PlaceHolderAdditionalPageHead.

<script type="text/javascript" src="/_layouts/15/SP.UserProfiles.js"></script> 

It will already have references to SP.UserProfile.js and App.js

<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="../Scripts/App.js">

Open the App.JS and replace its current code with the following code

var personProperties;
// This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
$(document).ready(function () {
    //    getUserName();
   
    SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, ‘SP.UserProfiles.js’);
   
});

function getUserProperties() {

   
    //set your user id, the following format is the user id for Office 365. If you are reading it from SharePoint OnPremise assign user id in the DomainUserId
    var targetUser = “i:0#.f|membership|UserID@SharePointSite.onmicrosoft.com”;

    //Instantiate Client Context
    var clientContext = new SP.ClientContext.get_current();

    //Instantiate People Manager
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

    // Get the instance of person properites
        personProperties = peopleManager.getPropertiesFor(targetUser);

    // Load the PersonProperties object and send the request.
    clientContext.load(personProperties);
    clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);
}

// This function runs if the executeQueryAsync call succeeds.
function onRequestSuccess() {

    // Get a property directly from the PersonProperties object.
    var messageText = ” “LastName is ” property is “
        + personProperties.get_userProfileProperties()[‘LastName’];

    // Get a property from the UserProfileProperties property.
    messageText += “<br />”WorkPhone Number” property is “
        + personProperties.get_userProfileProperties()[‘WorkPhone’];
    $get(“results”).innerHTML = messageText;
}

// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
    $get(“results”).innerHTML = “Error: ” + args.get_message();
}

Set the following permissions

app permission

ReadUserProfile

 

 Subscribe to my blog

 

 

How to add a Calender App to Office 365 E3 public SharePoint Site

In this article, I’d deal with how to add a Calender App to Office 365 E3 public SharePoint site.  I came across this scenario when I was designing an Office 365 public facing site for the User Group in Chennai. When you subscribe for an Office 365 E3 subscription, you’ll get a public facing Sharepoint site.

Office 365 E3 Calender1

You’ll see a Calender App missing in the Site Contents when you try to add an App. You need to employ an work around to achieve this one.

Add Custom List App

Office 365 E3 Calender2

Go to List Settings –> Advanced Settings –> Enabled Management of Content Types

Office 365 E3 Calender3

Add from existing Site Content Types

Office 365 E3 Calender4

Click Ok.

Change new button order and default content type and set Event as default content type

Office 365 E3 Calender5

Now we have added the Calender App and we create events here.

 

 

 Subscribe to my blog

Deprecation of Custom Managed Code in Sandbox Solutions

Microsoft SharePoint product team has officially clarified yesterday that they are deprecating managed code in Sandbox Solutions.

http://blogs.msdn.com/b/sharepointdev/archive/2014/01/14/deprecation-of-custom-code-in-sandboxed-solutions.aspx

This will impact us if we are working on migration to Office 365 SharePoint online.

If you have customization in existing SP 2010 environment, please consider the following alternatives if you want to move to Cloud.

http://blogs.msdn.com/b/richard_dizeregas_blog/archive/2013/07/16/app-approaches-to-common-sharepoint-customizations.aspx

 Subscribe to my blog

How to set Profile Picture in Office 365 SharePoint 2013 site using CSOM

Step1

Create a console application in Visual Studio 2013.

Step2

Import the following namespaces

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.UserProfiles;

using System.Net;
using System.Security;
using System.Globalization; 

Step3

Add the following references

Step4

            Uri oUri = new Uri("https://yoursite.sharepoint.com");

            Office365ClaimsHelper claimsHelper = new Office365ClaimsHelper(oUri, "youruserid@yoursite.onmicrosoft.com", "password");
            using (ClientContext oClientContext = new ClientContext(oUri))
            {
                oClientContext.ExecutingWebRequest += claimsHelper.clientContext_ExecutingWebRequest;
                PeopleManager oPeopleManager = new PeopleManager(oClientContext);
                
                Stream oStream = new FileStream(@"C:MyPhotoSundar.jpg", FileMode.Open);
                oPeopleManager.SetMyProfilePicture(oStream);
                oClientContext.ExecuteQuery();
                Console.Write("Profile picture is set");



                Console.ReadLine();
            }

How to read UserProfile property from Office 365 SharePoint 2013 site using CSOM

Step#1

Create a console application in Visual Studio 2013

Step#2

Import the following namespaces

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Taxonomy;

using System.Net;
using System.Security;
using System.Globalization;

Step#3

Add references to the following .dll

references

Step#3
 static void Main(string[] args)
        
        {
            ReadUserProfile();
            
           
        }

        public static void ReadUserProfile()
        {
            Uri oUri = new Uri("https://yoursite.sharepoint.com");

            Office365ClaimsHelper claimsHelper = new Office365ClaimsHelper(oUri, "youruserid@yoursite.onmicrosoft.com", "password");
            using (ClientContext oClientContext = new ClientContext(oUri))
                        {
                            oClientContext.ExecutingWebRequest += claimsHelper.clientContext_ExecutingWebRequest;
                PeopleManager oPeopleManager = new PeopleManager(oClientContext);
                PersonProperties oPersonProperties = oPeopleManager.GetPropertiesFor("i:0#.f|membership|youruserid@yoursite.onmicrosoft.com");
                
                oClientContext.Load(oPersonProperties, p => p.AccountName, p => p.UserProfileProperties);
                oClientContext.ExecuteQuery();

                Console.WriteLine(oPersonProperties.UserProfileProperties.Count.ToString());
                
                foreach (var oProperty in oPersonProperties.UserProfileProperties)
                {
                    Console.WriteLine(string.Format("{0}: {1}",
                        oProperty.Key.ToString(), oProperty.Value.ToString()));
                    
                }
                Console.ReadLine();

            }

CSOM userprofile

The account parameter to be passed for the method oPeopleManager.GetPropertiesFor is not straight-forward. For office 365 SharePoint accounts, the parameter has to be passed in this format "i:0#.f|membership|youruserid@yoursite.onmicrosoft.com". Replace the youruserid accordingly.

The complete source code for this article is available in this location

 Subscribe to my blog