How To Create a Publishing Page in SharePoint Online Using CSOM API

I am working on some provisioning code for SharePoint Online, and I needed to create a publishing page.  After some digging into the CSOM API, here is the code for adding a publishing page in SharePoint Online.

image

using (ClientContext ctx = Login(parentURL))
{
     try
     {
         var web = ctx.Web;
         ctx.Load(web);


        PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(ctx, web);
         ctx.Load(publishingWeb);


        if (publishingWeb != null)
         {
             string pageLayoutDisplayName = “ArticleLeft”;
             // Get Publishing Page Layouts
             List publishingLayouts = ctx.Site.RootWeb.Lists.GetByTitle(“Master Page Gallery”);
             ListItemCollection allItems = publishingLayouts.GetItems(CamlQuery.CreateAllItemsQuery());


            ctx.Load(allItems, items => items.Include(item => item.DisplayName).Where(obj => obj.DisplayName == pageLayoutDisplayName));
             ctx.ExecuteQuery();


            ListItem layout = allItems.Where(x => x.DisplayName == pageLayoutDisplayName).FirstOrDefault();
             ctx.Load(layout);


            List pages = ctx.Site.RootWeb.Lists.GetByTitle(“Pages”);
            
             PublishingPageInformation publishingPageInfo = new PublishingPageInformation();
             publishingPageInfo.Name = “test.aspx”;
             publishingPageInfo.PageLayoutListItem = layout;
            
             PublishingPage publishingPage = publishingWeb.AddPublishingPage(publishingPageInfo);


            List publishPageParentList = publishingPage.ListItem.ParentList;
             ctx.Load(publishPageParentList, list => list.EnableModeration);
             ctx.ExecuteQuery();


            publishingPage.ListItem[“PublishingPageContent”] = “test”;
             publishingPage.ListItem.Update();
             publishingPage.ListItem.File.CheckIn(string.Empty, CheckinType.MajorCheckIn);
             publishingPage.ListItem.File.Publish(string.Empty);


             if (publishingPage.ListItem.ParentList.EnableModeration)
                 publishingPage.ListItem.File.Approve(string.Empty);


            ctx.Load(publishingPage);
             ctx.Load(publishingPage.ListItem.File, obj => obj.ServerRelativeUrl);
             ctx.ExecuteQuery();


        }

public ClientContext Login(string URL)
         {
             SecureString passWord = new SecureString();
             foreach (char c in Password.ToCharArray()) passWord.AppendChar(c);
             ClientContext tenantContext = new ClientContext(URL);
             tenantContext.Credentials = new SharePointOnlineCredentials(Username, passWord);
             return tenantContext;
         }


A couple key notes for those interested:

  • Publishing pages require a page layout – in this case “ArticleLeft”.  The publishing page object is looking for the actual list item representing the page layout which requires you finding it and providing it.  This is what the first few lines of code are doing – looking up by Display Name the page layout for ArticleLeft.
  • In order to approve a page, content approval has to be turned on in the list.  If it’s not turned on and you run the “publishingPage.ListItem.File.Approve” method it will generate an exception.  You can check for it being turned on using the “EnableModeration” property.
  • Like most properties in CSOM, you have to explicitly load properties.  If you try to access the property and it hasn’t been loaded you will get an exception.  This is what the line “
  • ctx.Load(publishPageParentList, list => list.EnableModeration);” is doing – it’s requesting that property be explicitly loaded.

  • The pagename property is ithe physical name of the page and it has to end in “.aspx” or you will get an exception.
  • Once you have created the page, you can then set the content of the various fields within the page as well.  In this case, I successfully updated the field “PublishingPageContent” (which is the main content box in the ArticleLeft page template) with the string “test”.  This would allow you to inject any content into those boxes.

I haven’t tested it but I expect that this would also work in SharePoint 2013/2016 on premise as well.

Read More

If Your Hybrid Search Index lives in the Cloud, is this a Compliance Concern?

One of the new features in SharePoint 2016 is the ability to integrate content from on premise SharePoint Farms with Office 365.  

The Old Model

In the original SharePoint 2013 model, Hybrid Search worked by using a federated search approach where the SharePoint 2013 farm hosted the search index for on premise and Office 365 hosted the search index for SharePoint Online. 

While the search query executes within Office 365, the index is actually still on premise and is federated with the SharePoint online search index.  The content within the on premise index never leaves the on premise farm.

The New SharePoint 2016 Model

With the new SharePoint 2016 model and/or the latest SharePoint 2013 model (it requires the latest cumulative update), there is no longer an on premise index and a cloud index.  There is only a single integrated index running in the cloud.

The key point here is the content that is indexed is now in the cloud at least as represented as the stored index, even if it originated from an on premise SharePoint farm..

There are clear advantages to this approach in that SharePoint Online now has a single index to search and can use ranking, relevance, Delve, activity feeds, etc. against a consolidated index that covers content both on premise and in the cloud.

The Key Compliance Question: If Your Content is Indexed in the Cloud, is it in the Cloud?

Many regulated organizations have made it a policy that certain types of documents cannot be hosted in the cloud.  They implement SharePoint 2013 on premise to avoid the security and compliance risks associated with moving to the cloud.   A typical hybrid scenario involves for example a hospital that might allow for collaboration of non-patient records in Office 365 but keeps all patient records on premise for compliance and security reasons.

In this scenario, any document on premise would be crawled and indexed by SharePoint online using SharePoint 2016.  Crawled document content and metadata is now in the cloud – for example, all metadata attributes would be the index as well as all words/terms from the content of the document.  If your document contains patient identifiers as metadata or within the content of the document, those now presumably live in some form within the index (The original document stays on premise – when the user clicks on the link it sends them back to the on premise SharePoint farm).

Is this a compliance violation if the policy is no patient records can go to the cloud? 

Read More

SharePoint 2016 Release Candidate Now Available

Microsoft has just announced the availability of SharePoint 2016 Release Candidate.  It is now available for download here.

A release date hasn’t been announced but it is expected to be Q2 2016.  The fact that there is a Release Candidate is a good sign on the progress of the SharePoint team.

Project Server 2016 is also available as a release candidate.

Read More

Top 10 Microsoft Trends to Look for in 2016

As we start off 2016, there are a number of Microsoft announcements, new products and services to look forward to in 2016 – here is the top list of exciting trends we see in 2016 from Microsoft.

1. Power BI Continues Expansion

Power BI was re-launched in 2015 and so far since the summer has had several updates.  The service is now on the same growth in maturity curve that Office 365 was a couple years ago with every month delivering new features, enhancements and announcements.

While still not at the same level as best of breed BI suites such as Tableau or Qlik, Microsoft is very serious about taking on this market and is making massive investments in product development.  Combined with the eco-system play that integrates Power BI with Azure and legacy on premise data sources (all running Microsoft’s products), Power BI will see continued expansion and maturity growth in 2016.

2. SharePoint 2016 Is Released

SharePoint 2016 is the latest version of Microsoft’s on premise collaboration system and will provide a deeper integration with Office 365 to ease the transition to the cloud.  SharePoint 2016 doesn’t have a lot of killer new features other than better hybrid integration but may be the excuse to move some organizations from SharePoint 2007 or 2010 to the latest version and to have a further conversation about what collaboration, intranets and document management mean for a modern organization.

image

3. NAV 2016 Comes to the Cloud

NAV is Microsoft’s SMB ERP suite and is positioned between Great Plains and AX as the Swiss army knife of ERP systems.  NAV 2016 is being released soon and will be the key ERP system from Microsoft that is particularly suited to cloud deployments.  For example, it has support for Azure SQL so that you don’t have to run your own SQL cluster in Azure IAAS.  It also has deep integration with both Office 365 and Dynamics CRM Online.

For those looking for a cloud ERP solution, NAV 2016 might be the key solution.

4. Bundling of Azure Services

One of the key challenges with dealing with Microsoft Azure is the sheer number of services available in various configurations.  Microsoft has recognized this and is starting to bundle services into packages that can be explained to executives as a suite.  For example, look for the Cortana Suite to be promoted heavily as an end to end data analytics service in 2016.

What is Cortana Analytics

Another example is the IoT Suite which is a bundling of IoT Hub, Machine Learning, Stream Analytics, Notification Hubs and Power BI. 

These suites align the hundreds of Azure services now into specific purpose built bundles to sell to executives looking for big data, IoT, etc.

5. Machine Learning Solutions for Business

Machine learning is an exciting set of technologies, processes and techniques that allows for prediction based on statistical models.  Microsoft released Azure-ML which provides a workbench in the cloud for running machine learning experiments and creating analysis models. 

Expect Microsoft to move up the value chain with machine learning and start providing more business friendly and targeted industry solutions.  They have already worked on algorithms for basic processes such as fraud detection, production recommendations, etc. – expect this to continue and expand in 2016. 

6. SQL Server 2016 Released with New Reporting Capabilities

Microsoft bought a company called DataZen in 2015, acquiring some mobile business intelligence technologies for providing dashboards.  This technology is now being integrated into the new SQL Server Reporting Services as part of SQL 2016. 

With Power BI evolving in the cloud, SQL Server 2016 will provide a much needed update to SQL Server Reporting Services including support for responsive HTML 5 reports, mobile dashboards and integration of Power BI into SSRS and vice versa.

7. CRM 2016 Released Integrating Recent Acquisitions

Microsoft acquired a number of companies in the CRM space in 2016 including FieldOne and ADX Studio.  Microsoft will release CRM 2016 that provides a number of new features and integrates these new acquisitions into the product.

With the FieldOne acquisition, Microsoft Dynamics CRM will now provide field service management capabilities into Dynamics CRM including scheduling of work orders, work force management, etc.

8. Microsoft’s Azure Big Data Services Mature

Microsoft released a number of big data services in 2015 including Azure Data Warehouse, Azure Data Lake, Spark on HDInsight and Azure Data Catalog in preview.  In addition, services such as Azure SQL and HDInsight have been upgraded significantly since their first release.  While the services are there, they don’t all quite integrate together and they have differing levels of maturity.

Expect further consolidation and investment in the Big Data services eco-system as Microsoft is investing heavily in this area.  Many of the services currently in preview will be released as general availability in 2016 and considered to be production ready.

9. Microsoft Goes RAD Again

Microsoft has been a pioneer with Rapid Application Development tools going back to the days of Visual Basic and Microsoft Access.  They have continued to try and provide a set of development tools for light weight development scenarios in various flavors including LightSwitch, InfoPath, Silverlight, SharePoint, CRM, etc.

Recently, Microsoft has been releasing a number of tools for building applications without hard core development required.  These include:

  • Microsoft Power Apps
  • Azure App Service
  • Microsoft Office Sway

While Sway isn’t strictly a development platform, it provides interactive HTML 5 based content delivery using Office 365.  Power Apps provides a pseudo application development platform for creating applications based on Office 365 content and other cloud services.  The Azure App Service provides the ability to create logic apps that integrate data from various cloud services into business process workflows.

All of these tools are trying to accomplish the same objective – allow businesses to use the Microsoft tools and services with reduced complexity, faster time to market and less reliance on developers to build applications with basic requirements.

10 Organizations Lag Behind

With all these new services, the reality is that most organizations won’t adopt them in 2016.  There are lots of organizations who are still on SQL 2005, SharePoint 2010 or CRM 4.0.  Organizations will struggle to adopt these new services as the pace at which Microsoft is pushing out releases is now outstripping the ability for organizations to leverage these new technologies and deploy them successfully.

Read More

SharePoint 2016 Preview Release Now Available

Microsoft has made available for download the first preview release of SharePoint 2016.  The download.  The SharePoint 2016 IT Preview release, as it has been called, is now available to installed.

SharePoint Server 2016 IT Preview has been designed, developed, and tested with the Microsoft Software as a Service (SaaS) strategy at its core. Drawing extensively from that experience, SharePoint Server 2016 IT Preview is designed to help you achieve new levels of reliability and performance and empower users while meeting their demands for greater business mobility.

Microsoft has also provided:

These are documents just posted today that describe the new features and installation steps for this new version of SharePoint.

Read More

SharePoint 2013 Update Released to Enable Hybrid Search with Office 365

Microsoft has just released the anticipated update for SharePoint 2013 on premise.  Along with fixing some bugs, the key feature for this update is the enablement of improved hybrid search integration with Office 365.

There is also now a hybrid sites feature that consolidates Followed Sites between SharePoint 2013 on premise and Office 365.

image

In the old hybrid search scenario, you can enable searching of on premise content from Office 365 and vice versa.  However, in the old scenario, the indexes are still separate from each other and when you search they are treated as separate.

In the new hybrid search, you can now create a true hybrid index that combines search results from Office 365 and SharePoint on premise in a single index.

image

Read More

No Foundation Version in SharePoint 2016

Microsoft runs a Yammer group called the Office 365 Network where a number of SharePoint experts and Microsoft employees congregate to talk about SharePoint and Office 365.

Within this group, Bill Baer announced that a Foundation version will not be shipped as part of SharePoint 2016.  SharePoint Foundation has been part of SharePoint for many years as a free version shipped with Windows.  As of SharePoint 2016 it looks like this version will be retired.

image

Bill also put up a tweet here asking for feedback on the issue.  You can see lots of replies from potentially affected customers.  Bill has also provided his email so you can provide feedback directly if you’re worried about losing the Foundation version in the next SharePoint.

image

Read More

New Features Coming in SharePoint 2016

A number of details were announced at Ignite today on SharePoint 2016.  Here are some of the key highlights and interesting features that were announced at various sessions.

image

Easier Hybrid Setup

There are a number of new features in SharePoint 2016 to enable hybrid scenarios and to provide a more seamless experience to users who have a mixed environment and who are looking to take advantage of some of the cloud based offerings in Office 365 while still keeping SharePoint running on premise for some workloads.

A new hybrid configuration wizard replaces complex PowerShell scripts with a wizard experience for common scenario.

True Hybrid Search

In the current hybrid search scenario, you can enable searching of on premise content from Office 365 and vice versa.  However, in the current scenario, the indexes are still separate from each other and when you search they are treated as separate.

In SharePoint 2016, you can now create a true hybrid index that combines search results from Office 365 and SharePoint 2016 on premise in a single index.

image

Surfacing of On Premise Content in Delve

Delve will support surfacing of on premise content from SharePoint 2016.  This means that you can have a single delve activity feed that provides access to both Office 365 and SharePoint on premise content in a single view.

image

This delve feature will also be coming to SharePoint 2013 as an update later this year!

Mobile UI Coming to SharePoint 2016

Office 365 has a touch mobile UI and this will be coming to SharePoint 2016. 

image

Durable Links

One of the key features that have been a challenge for many versions is the management of URLs as durable instead of changing as documents are moved around.  In previous versions  of SharePoint, you could turn on the Document ID service to generate unique IDs for your documents but it was specific to a site collection. 

image

The service also handles the context switching of URLs as documents are shared on premise, through guest access, or through external sharing.

New Boundaries and Limits

SharePoint 2016 will have expanded boundaries and overcome some of the existing limits in SharePoint 2013.

image

New Infrastructure Roles

There is a concept around application service roles for setting up the SharePoint 2016 infrastructure.  There is a new Server Role installation wizard that better isolates and segments the tiers in the infrastructure.  This will also help to reduce the data center footprint compared to previous versions and make it easier to patch the farm.

image

Zero Downtime Patching

Microsoft is promising “zero downtime patching” which will mean you can apply patches while keeping the SharePoint farm online!

Read More