Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

    Advertisements
  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

Posts Tagged ‘sharepoint’

SharePoint Framework – New SharePoint 2016 Development Model

Posted by Paul on September 27, 2017

SharePoint Framework (SPFx) was introduced in early 2017 and it is the Preferred Development Method for SharePoint 2016 and SharePoint Online.

Image result for sharepoint framework

Advantages of SPFx

  • Page and Web Part Model – No IFrame so increased performance
  • Runs in context of Current User – better context permission accessibility
  • Responsive Controls – easier rendering in mobile & tablet devices
  • Full-fledged JS support – easier integration of React, Angular frameworks
  • Free web parts – faster development on common scenarios

History of SharePoint Development Models

As an early starter with SharePoint, I would like to list down the SharePoint Development models from my mind.

Farm Solutions

This was the Initial development world.  It consisted of C# code in DLLs running in the server-side.  Later this led to issue of Full Trust and Poor code affecting whole server.

SharePoint 2003, 2007, 2010, 2013 had full support for Farm Solutions.

Sandboxed Solutions

Then came the Sandboxed Solutions which tried to resolve some of the Farm Solution issues.  Sandboxed Solutions set Trust configuration, Restricted Code, Quota Limit there by preventing a Poor Code from hampering server.  Still the code runs in Server-side leading to performance issues when a large number of users using a Dashboard web part for example.

Here the C# code will be executed on SharePoint server.

SharePoint 2007, 2010, 2013 had support for Sandboxed Solutions.

CSOM

Client-Side Object Model (CSOM) was developed to address few of the Sandboxed Solution issues.  CSOM still uses C# code but can be executed outside the SharePoint server.  This freed up the SharePoint Server from unwanted loads and also relaxed on the Deployment overheads with just referring to Client Side DLLs.

SharePoint 2010, 2013 supported CSOM.

JSOM

JavaScript Object Model (JSOM) bought the Client Side Object Model advantage to the SharePoint pages.  Here the JavaScript code will be executed in the Client browser there by Freeing up Server Performance cycles. 

JSOM also supported Batching which was earlier boon to reduce server roundtrips.

The initial way of executing JavaScript was attaching code file with a Script Editor web part.  Later JSOM usage evolved as Solid Client Side Applications through usage of Angular, React and other JavaScript frameworks.

SharePoint 2010, 2013 supported JSOM.

Apps

Apps (Now Add-ins) was introduced in SharePoint 2013 to package & publish complete applications to Corporate or Office 365 store.  In this way the client side support was extended to business level.   Apps came with SharePoint Hosted Apps (SHA) initially.

Apps also provided PHA (Provided Hosted Apps) which allow running C# code in outside servers.

Apps were using IFrame and thus cause redirection & page load delays.

SharePoint 2013, 2016 supported Apps.

SPFx

SharePoint Framework (SPFx) was introduced in SharePoint 2016 to address the problems with Apps.  There are No IFraames thus increasing the Page Performance.  SPFx also comes with ready made reusable web parts for common functionalities.

SharePoint 2016 supports SPFx.

References

https://docs.microsoft.com/en-us/sharepoint/dev/spfx/sharepoint-framework-overview

Advertisements

Posted in SharePoint, SharePoint 2016 | Tagged: , , | Leave a Comment »

Webhooks in SharePoint 2016

Posted by Paul on July 28, 2017

SharePoint 2016 introduced Webhooks for List Event Handling.  Webhooks are much better than Remote Event Receivers.

Webhook

Webhooks are enabled on SharePoint list items

Webhooks allow developers to Subscribe list item changes

Webhooks support only Asynchronous events

Webhooks requires a Target URL

Subscription

You need an Office 365 Subscription to test Webhooks.

You need to create a List Event subscription on the required List

You need to setup a Server URL to host the Webhook URL

Subscription can be enabled with an Expiration Date

Code

The class need to be inherited from SPWebhookNotification class.

The class should implement properties for SubscriptonId, ClientState etc.

Http Post attribute should be used for the receiver method.

Posted in SharePoint, SharePoint 2016 | Tagged: , , | Leave a Comment »

Sandboxed Solution & SharePoint Online Compatibility

Posted by Paul on February 12, 2017

In this article we can explore Compatibility of Sandboxed Solution with SharePoint Online.

Scenario

I am seeing that many developers are recommending Sandboxed Solutions for On-Premise and Online deployments.

But, the Twist is that SharePoint Online does not support all sandboxed solutions. So if your solution has a Strategy Architecture comprising of SharePoint Online, you need to be really careful recommending Sandboxed Solutions.

Recommendation

Sandboxed Solution is of two types:

1. No-Code Sandboxed Solution (NCSS)

2. Code Sandboxed Solution

image

NCSS contains only HTML & CSS markups. No code will be there.

Recommendation

NCSS is the recommended & only allowed one in SharePoint Online.

Testing

Create a new Sandboxed Solution.

image

Add a Visual Web Part. Do not add any code. Build the project.

Now Upload the NCSS and we get the Activate button enabled. This proves No-Code Sandboxed Solutions can be activated in SharePoint Online. (as of today)

image

Now come back to Visual Studio & Add place a button on the Visual Web Part.
image

Add code to the click event handler.

image

Build the project.

Now upload the Coded Sandboxed Solution to SharePoint Online. You can see the Activate button is disabled.

image
So this demonstrates that SharePoint Online does not support Coded Sandboxed Solutions.

image

Sandboxed Solutions were the Solutions of the past and now being deprecated. In the modern SharePoint development world REST, CSOM, Apps are the recommended approaches. Plus, there is a risk that Sandboxed Solution can get disabled in future versions of SharePoint/Online.

References

https://blogs.msdn.microsoft.com/sharepointdev/2014/01/14/deprecation-of-custom-code-in-sandboxed-solutions/

Summary

In this article we have explored Compatibility of Sandboxed Solution with SharePoint Online.

Posted in SharePoint, SharePoint 2013 | Tagged: , , , | Leave a Comment »

Playing Video in Restricted SharePoint Environments

Posted by Paul on January 25, 2017

Few months back I came across a scenario where User wanted to play Video in SharePoint Pages. But the Environment restricts usage of Video Streaming.

Solution

In this case we can use HTML5 Video Tags.

HTML5 Video

HTML5 included the Video & Audio tags which allows playing multimedia without any extra plugin requirement.

Previous to HTML5, Flash Or Media Player was required to play video Or audio files. Now all HTML5 compatible browsers support the Video tag by incorporating necessary multimedia infrastructure within them.

Following are the Browsers & Versions supporting HTML5 Video & Audio tags.

image

Reference: http://www.w3schools.com/html/html5_video.asp

SharePoint & Video Tag

Coming back to our problem, Perform the following activities for testing the Video tag.

Open SharePoint Designer. Go to Site Pages.

image

Choose the new HTML or ASPX option. Edit the file. Add the following code inside body tag.

<video width=”300″ height=”250″ controls>
<source src=”/siteassets/video.mp4″ type=”video/mp4″>
  Your browser does not support the video tag.
</video>

The code performs the following:

· Set the Video tag with wdith & height

· Specify the source as mp4 file

· Set the Error text if browser does not support video tag

Your code in HTML file looks like below.

image

Video File

Now we need to create a video file. You can download the Video file from link below.

http://techslides.com/sample-webm-ogg-and-mp4-video-files-for-html5

image

Choose the MP4 file, download, rename & upload to Site Assets library.

image

Testing

Now open the HTML file in a Video supported browser. You will get the video played as shown below.

image

Now open the HTML file in a non-supported browser. You will see the following error message.

image

image

You can also set a Preview Image for the Video tag. This image will be displayed in the non-play state.

Restricted Scenarios

The video restricted scenarios can be:

1. SharePoint Restricted Content Types

2. SharePoint Restricted File Extensions

3. IIS Video Streaming Restrictions

References

http://www.w3schools.com/html/html5_video.asp

Summary

In this article we have explored using Video Tag for a restricted SharePoint environment scenario.

Posted in SharePoint, SharePoint 2013 | Tagged: , , , , | Leave a Comment »

Claims Viewer Web Part – Installation

Posted by Paul on June 17, 2016

In this article we can explore how to Download & Install the claims viewer web part for SharePoint 2013.

Download

You can go the following location to get the web part:

https://sharepoint2013claimsviewer.codeplex.com/

From there choose the Downloads page:

image

You will get the WSP file.

image

The web part is Free for development & commercial use.

Installation

Once you have downloaded the WSP file, you need to install it. This is a Farm Solution so you require PowerShell.

Go to your SharePoint Server & Open the PowerShell window in Administrator mode.

image

You will get the following command window.

image

Run the following command to add the WSP package to Farm Solutions.

· Add-SPSolution “full path”

· Eg: Add-SPSolution “c:shared ClaimsViewerWebPart2013.wsp”

If things went well, you will get the following message.

image

Now run the following command to install the WSP package.

· Install-SPSoluiton ClaimsViewerWebPart2013.wsp –gacdeployment –webapplication http://yourserver

If things went well, you will the following output with no error messages.

image

Now you can come to your SharePoint site > Go to Site Collection features > Activate the following feature.

image

Once you have activated the feature, you can add the Web Part to a page.

Create a new page & choose the Insert web part option. You should be able to see the Claims web part as shown below.
image

Insert the web part & Save the page. You are ready to use the Claims Viewer web part.

image

image

Your claims may be different from the items shown above.

References

https://sharepoint2013claimsviewer.codeplex.com/

Summary

In this article we have explored how to install the Claims Viewer web part.

Posted in SharePoint, SharePoint 2013 | Tagged: , , , | Leave a Comment »

Claims Viewer Web Part

Posted by Paul on June 5, 2016

In this article we can explore the Claims Viewer Web Part.

About Web Part

I was working in a Claims enabled SharePoint Web Application where I felt the need of a Claims Viewer component which could display the current claims of the logged-in user.

Download

You can go the following location to get the web part:

https://sharepoint2013claimsviewer.codeplex.com/

Example

An example is displayed below.

image

Web Part

The above component is developed as a Web Part and requires Farm Solution for deployment. The C# code runs in the server-side and renders the claims values to the output.

Code

Following is the code which retrieves the claims.

protected void Page_Load(object sender, EventArgs e)

{

IClaimsPrincipal principal = Thread.CurrentPrincipal as IClaimsPrincipal;

IClaimsIdentity identity = principal.Identity as IClaimsIdentity;

IList<ClaimEntity> list = new List<ClaimEntity>();

foreach (Claim claim in identity.Claims)

list.Add(new ClaimEntity()

{

ClaimType = claim.ClaimType,

Value = claim.Value,

ValueType = claim.ValueType

});

RefreshGrid(list);

}

Once the user is logged in, the thread will contain the Claims Principal object. We can get the Claims from this object.

Each claim will have the following:

· Claim Type which is the pre-defined URL eg: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier

· Claim Value which is the actual claim value eg: windowsadministrator

image
You can use the References for articles on Installation of the Claims Viewer web part.

References

https://sharepoint2013claimsviewer.codeplex.com/

Summary

In this article we have explored the usage of Claims Viewer web part.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

Confusion with Site Definition & Site Pages

Posted by Paul on February 17, 2016

One of my co-worker raised a concern over editing Site Pages in Advanced Mode. This is regarding my previous article Sleek Way Of Developing Fully Immersive SharePoint Pages.

The argument raised was “We should not edit Site Definition” due to the reasons mentioned in the article here. Please refer the section on it.

image

I would like to clarify this here as more people would be thinking the same.

image

Site Definition vs. Site Pages

The core point of clarification is Site Definition is different from Site Pages.

Site Definition consists of:

· Web Parts

· Workflows

· XML Files

· Lists & Libraries

So Site Definition is a Package of Solution.

For example, Let us take example of Publishing Site Definition.

Publishing Site Definition

As you know Publishing Site Definition provides the following advantages:

· An author can create content using a page template

· Content will be reviewed & approved by Approvers

· Content gets Published

To incorporate all these functionalities, the Publishing Site Definition has:

· Built-in Permission Groups

· Built-in Workflows

· Built-in Pages

· Built-in Code

So, if we are going & modifying the above Site Definition using SharePoint Designer Advanced Mode editing, we are risking the following:

· Future updates to above Site Definition will not be applied

· Future SharePoint upgrades can break functionalities

image

Normal Mode Editing is done through Browser & only the content in Web Part Zone is edited. Advanced Mode Editing is done through SharePoint Designer Advanced Mode. Here the page area which cannot be accessible in Normal Mode Editing too is editable. This causes detaching from Site Definition formats.

Our Case

Coming back to our case of Site Pages, we are clearly not breaking any functionality. Following are the reasons:

· We are just using a Site Page & not a Site Definition

· We do not use any Site Definition features like Workflows, Approval etc.

· We are inheriting a Standalone ASPX page with less minimal SharePoint tags

The following link too recommends Advanced Mode editing.
image

Conclusion

The conclusion is we can continue with Advanced Mode editing of our Standalone ASPX Pages.

image

You can also use notepad for creating the above Site Page. No special requirement for SharePoint Designer.

References

https://support.office.com/en-us/article/Create-SharePoint-site-pages-0ee31678-ee55-40cd-9f48-ea8700035dbd

https://support.office.com/en-us/article/Managing-SharePoint-Designer-2010-E12D76CE-83F7-4DDE-864C-6C1E210399B6

Summary

In this article we have clarified a Confusion scenario with Site Definition & Site Pages.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

BCS External Content Type Configuration

Posted by Paul on February 7, 2016

 

In this article we can explore how to configure BCS External Content Type in SharePoint 2013.

BCS

BCS (Business Connectivity Services) allows Interfacing to Data that does not Live in SharePoint. For example, we can connect to External Databases, OData Sources etc.

When to use BCS?

The ideal scenarios to use BCS are:

· To leverage an existing SQL Server Table containing Data. BCS would free us from duplicating the Table in SharePoint. BCS also saves the cost involved in Synchronizing Data if there are users working on updating the source table.

· In Internal SharePoint application requiring data from External application. In this case we can create Custom .Net BCS Providers.

BCS Example

In our example we are creating a BCS List pointing to SQL Server Table. Please follow the steps below to create the BCS List in SharePoint. After the List creation, you will be able to Add/Edit/Delete items in the List & everything will reflect back in the SQL Server Table.

Step 1

Create a new SQL Server table named Customer.
image

Use the following structure:

1. Id Integer Identity

2. Name Nvarchar (max)

3. Address Nvarchar (max)

Fill the Table with some data as shown below.
image

Step 2

Open SharePoint Designer 2013 & Go to External Content Types pane as shown below.

image

Choose the External Content Type button from the left pane for creating a New External Content Type. (External Content Type is the keyword for referring BCS Content Types)

Enter the Name for the Content Type and click the highlighted area below to configure External Data Source.

image

You will get the following dialog. Choose Add Connection option.

image

In the appearing dialog choose SQL Server.

image

Enter the Credentials to SQL Server.
image

Choose our table. Right click and choose Create All Operations.
image

You will get the following wizard.

image

Click Next with default values.

Step 3

Now we need to create the List Instance. Go to Lists and Libraries in Designer and click the External List ribbon item.

image

Choose our Content Type from the appearing dialog box.

image

Click OK to continue. Enter the name as Customers for the list. Now you have successfully created the List Instance of our External Content Type.

Step 4

Now we can Test our new List. Open SharePoint & You should be able to see the Customers list in the Quick Launch. Click on it to see the items below.

image

Once you can see the data like above – You have successfully configured BCS External Content Type.

Errors

It is not surprising that you may get the following errors. You can refer the associated links to resolve them.

Access denied by business data connectivity.

http://www.jeanpaulva.com/index.php/2016/01/23/bcs-error-access-denied-by-business-data-connectivity/

Login failed for user

http://www.jeanpaulva.com/index.php/2015/12/27/bcs-error-login-failed-for-user/

AuthenticationMode RevertToSelf

http://www.jeanpaulva.com/index.php/2015/10/18/bcs-error-authenticationmode-reverttoself/

References

https://technet.microsoft.com/en-us/library/ee661740.aspx

Summary

In this article we have explored how to configure BCS External Content Type in SharePoint 2013.

Posted in SharePoint, SharePoint 2013 | Tagged: , , , | Leave a Comment »

Sleek SharePoint Pages!

Posted by Paul on February 3, 2016

In real-world projects I have noticed the following SharePoint Branding mistakes.

1. Inheriting a Publishing Page for a Fully Immersive UI where we don’t actually use any Publishing functionalities like Page Layouts, Approval Workflow, Content Authoring etc.

2. Using Content Editor web part to dynamically invoke an HTML file there by delaying loading through unwanted SharePoint stuffs.

Incurred Costs

This will have immediate costs of:

· Increased Development Time

· Reduced Performance

· Increased Download Size

This will have future costs of:

  • Forcing client to purchase SharePoint Standard/Enterprise editions rather using the Free Foundation

Requirement Context

The requirement context here is to have a Fully Immersive Page without SharePoint Branding and allowing REST Operations.

Key Solution

I am providing a Key Solution which is:

1. Sleek in SharePoint Branding

2. Applicable for Fully Immersive Pages

3. Minimal SharePoint Contents loaded

4. SharePoint Foundation compatible

Steps

Open a SharePoint Designer and Choose Site Pages > Page ASPX option. 

p1

Now, Open Designer and Go to Site Pages library.

image

You can see our page is listed there and the Content Type is of Wiki Page.  We don’t worry about that since we are not using any Wiki Page functionalities.  Plus, our page is SharePoint Foundation compatible.

image

You can also use HTML page instead of ASPX. In this case we need to change the Web Application property to allow HTML extensions to render instead of download & work with more challenges.

Now open the Page and choose Edit file option.

image

You will see the following page with read-only mode.

p2

Click on the Advanced Mode to edit the contents.

image

You will get the page in edit-mode as shown below.

p3

 

From the Immersive Page Perspective, We are expecting a Full Custom Page which does not require any SharePoint Branding or Ribbon elements. The above Page fits our requirement.

Following is the page content.

<%@ Page Language=”C#” %>

<%@ Register tagprefix=”SharePoint” namespace=”Microsoft.SharePoint.WebControls” assembly=”Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>

<html dir=”ltr” xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head runat=”server”>

<meta name=”WebPartPageExpansion” content=”full” />

<meta http-equiv=”X-UA-Compatible” content=”IE=10″ />

<SharePoint:CssRegistration Name=”default” runat=”server”/>

</head>

<body>

<form id=”form1″ runat=”server”>

</form>

Your HTML content goes here..

</body>

</html>

You can save the page and test in browser. You can see now the SharePoint Branding elements got removed.

image

You can View the source. The source looks simple.

p4

Now you are ready to use the above Page Template for building the Fully Immersive Page with Responsive Or Non-Responsive web design.  Full Control! Sleek! Faster!

html

image

You can also use HTML page instead of ASPX. In this case we need to change the Web Application property to allow HTML extensions to render instead of download & work with more challenges.

The Challenge

Now we need to use JSOM or REST API on the ASPX page. Clearly, we cannot use API because it will throw lot of security errors. The solution is to include the Form Digest tag.

Form Digest tag marks the page with right Security Contexts. This will allow the page to do POST requests to modify the contents in SharePoint.

Following would be the modified code.

<SharePoint:CssRegistration Name=”default” runat=”server”/>

/_layouts/15/init.js

/_layouts/15/MicrosoftAjax.js

/_layouts/15/sp.core.js

/_layouts/15/sp.runtime.js

/_layouts/15/sp.js

Add Form Digest value too.

<form id=”form1″ runat=”server”>

<SharePoint:FormDigest runat=”server”></SharePoint:FormDigest>

Your HTML content goes here..

</form>

The additional contents added ensure that the Page is protected to Post data through APIs.

image

Since we are hiding SharePoint Ribbon, it will hide the User Display Name & Gear Icon too.  If you require these, I would recommend creation of a Custom DIV and Add those Items manually.

Insert Test

Now let us really test an item insertion. You can use the following link for that.

http://www.jeanpaulva.com/index.php/2016/01/23/insert-using-rest-api/

References

SharePoint Pages http://bit.ly/1SKXOrI

SharePoint Editions & Features http://bit.ly/1K0UyY5

Form Digest http://bit.ly/1QIKzWB

Summary

In this article we have explored a sleek way of developing Fully Immersive SharePoint Pages.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

BCS Error – Access denied by Business Data Connectivity

Posted by Paul on January 23, 2016

You will get the following error while first time configuring BCS.

· Access denied by business data connectivity.

image

Solution

Following would be the solution.

Open Central Administration > Manage Service applications > Click Business Data Connectivity Service.

image

In the appearing page click on the Set Metadata Store Permissions ribbon item.

image

You will get the following page. Here do the following:

· Enter Everyone and click Add button

· Check all the permissions listed below

· Check the Propagate Permissions too

Click OK button.
image

Now retry your BCS List in SharePoint.

Summary

In this post we have explored a common error while configuring BCS & steps to resolve it.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »