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

Archive for the ‘SharePoint 2013’ Category

Error: Apps are disabled on this site.

Posted by Paul on March 11, 2016

The error says that you have not configured App Urls.

You can refer to this article for creating App Urls.

Advertisements

Posted in SharePoint, SharePoint 2013 | Leave a Comment »

PHA : Where to generate the Certificate?

Posted by Paul on March 3, 2016

We need to generate the certificate from the SharePoint Server.  The Certificate authorizes the PHA server through the Issuer ID and Password.

Creating Certificate

Open SharePoint Server > Go to IIS > Root Site > Server Certificates

image

Choose Create Self Signed Certificate from the right hand side.

image

Enter a name.

image

You will get the certificate created.

image

For PHA Apps we need to Sign the Certificate.  You can refer to Signing here.

http://www.jeanpaulva.com/index.php/2015/05/08/sign-the-certificate/

Posted in SharePoint, SharePoint 2013 | 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 »

Item Level Permissions and Code Access

Posted by Paul on January 29, 2016

Item Level Permissions and Code Access

In this article we can explore how Item Level Permissions behave in Code Access scenario.

Item Level Permissions

We can enable Item-level Permission on a list so that only the Creator will be able to Read the item.  For other users the item won’t be displayed.

As an Administrator, you can go to the List > List Settings > Advanced Settings to enable Item-level Permissions.

i1

Testing from Browser Access

Create a new item as Administrator User.

i2

Now login as a different User who is just a Contributor.  You won’t’ be able to see the Admin item now.

i3

Now create a new item.

i4

Now login back as the Administrator or Site Owner & You can see both the items.

image.png

Site Collection Administrator or Site Owner can view all the Use Items.

Testing from Code Access

Now let us see the Item-level Permission applies to Code Access as well.  For this I am using CSOM Code with/without Network Credential class.

By default the code runs under Login User which is Administrator.

static void Main(string[] args)

{

ClientContext context = new ClientContext(“http://sharepoint“);

List list = context.Web.Lists.GetByTitle(“Restricted Contacts”);

ListItemCollection items = list.GetItems(CamlQuery.CreateAllItemsQuery());

context.Load(items);

context.ExecuteQuery();

foreach (var item in items)

{

Console.WriteLine(item[“Title”]);

}

 

Console.ReadKey(false);

}

Executing the Code you can see both the items are displayed.  Since we are Administrator user now.

i5

Now apply the Contributor User Credential to test the User Context.

ClientContext context = new ClientContext(“http://sharepoint“);

context.Credentials = new NetworkCredential(“tim”, “Welcome123”);

i6

This concludes that Item-level Permission applies to Code Access as well & Site Collection Administrators or Site Owner can view all items in both browser & code access scenario.

image.png

Item-level Permissions is a great feature.  Without this we would have required custom code to break the permission & assign permission to the created user.

References

http://bit.ly/1PYkb8o

Summary

In this article we have explored Item Level Permissions & CSOM Code with different User Contexts.

 

Posted in SharePoint, SharePoint 2013, Uncategorized | 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 »

Insert using REST API

Posted by Paul on January 23, 2016

In this article we can explore a simple code to Insert an Item using REST API.

Contacts List

Create a Contacts List for our purpose.

image

Script Inclusion

Following are the script files you need to include:

1. JQuery https://jquery.com/download/

2. JSON2 https://www.drupal.org/project/json2

You can copy the following script code with Microsoft & Yandex CDN links.

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.0.min.js

http://yandex.st/json2/2011-10-19/json2.min.js

Insert Code

Following is the Insert Code to Insert an item.

function test()

{

CreateListItemWithDetails(“Contacts”, _spPageContextInfo.webAbsoluteUrl, “New Contact”, success, failure);

}

function success()

{

alert(“success”);

}

function failure()

{

alert(“failed”);

}

function CreateListItemWithDetails(listName, webUrl, newItemTitle, success, failure) {

var itemType = “SP.Data.” + listName + “ListItem”;

var item = {

“__metadata”: { “type”: itemType },

“Title”: newItemTitle

};

$.ajax({

url: _spPageContextInfo.siteAbsoluteUrl + “/_api/web/lists/getbytitle(‘” + listName + “‘)/items”,

type: “POST”,

contentType: “application/json;odata=verbose”,

data: JSON.stringify(item),

headers: {

“Accept”: “application/json;odata=verbose”,

“X-RequestDigest”: $(“#__REQUESTDIGEST”).val()

},

success: function (data) {

success(data);

},

error: function (data) {

failure(data);

}

});

}

Invoke Code

Following would be the Invoke Code.

<input type=”button” value=”Click Me..” onclick=”javascript:test();”

Testing Code

You can use a new page & Content Editor web part to test the above code. On successful insert you should be getting the message below.

image

You can also verify the new item in the Contacts list.

image

This concludes Insertion using REST API code.

References

http://bit.ly/1R7kB11

Summary

In this post we have explored how to Insert an Item using REST API.

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

When to use BCS in SharePoint?

Posted by Paul on January 17, 2016

I have found that Non-SharePoint Guys are recommending BCS (Business Connectivity Services) without Rationale.  BCS is a good feature, but we have to understand the Costs & Implications before blindly using it!

Advantages

Following are the scenarios where BCS can turn to be an advantage:

  • Leverage You have an existing Database Table which users are currently updating.  In this case BCS provides a leverage of External List to connect to this table.  Thus SharePoint users can also work on the Database Table in a synchronized manner.  No additional coding / synchronizing efforts.
  • Support All editions of SharePoint On-Premise supports BCS.

Disadvantages

Following are the disadvantages of using BCS for new systems:

  1. SharePoint Online Not all Plans of SharePoint Online supports BCS.  So if you are designing a product that should be living in heterogeneous client environments – think before you decide.  Check References for more information.
  2. Item-level Permissions BCS do not support Item-level permissions since the data is residing on a different source like SQL table.
  3. Alerts Alerts are not supported in BCS External Lists.
  4. User Context You will need additional configuration efforts to Impersonate the User.
  5. Secured Store Service You might get into SSS overheads based on the Impersonation Models.
  6. Authentication Method Based on client SharePoint environment you may face difficulty in choosing right Authentication Method.  Check References for more information.
  7. Firewall Issues Since External Systems or SQL Databases live in Firewall Or Behind the scene infrastructures, there will be additional Configuration & Troubleshooting Efforts for a successful BCS Connection
  8. Automation Deployment If you are using Automation Deployment Scripts, you will need additional R&D time for writing the accurate BCS deployment steps.

Note

BCS can turnout to be a Leverage or Liability based on your Current & Future Requirements

References

https://technet.microsoft.com/en-us/library/sharepoint-online-service-description.aspx

http://sharepointpromag.com/sharepoint/6-lessons-developing-business-connectivity-services-solution

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

Summary

In this post we have examined few good & bad cases of using BCS.

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

SharePoint Page Performance Optimization

Posted by Paul on January 7, 2016

In this article we can explore few options to improve SharePoint Page Performance.

image

Page Performance

The usual NFR (Non-Functional Requirement) value for Page Response time is 3 seconds. This is the standard for a normal Intranet Deployment Scenario. So if your page is taking more than 3 seconds to load, then it is not a good sign.

SharePoint Page Performance Optimization

Following are few page performance optimization ideas which we can employ. Depending on one or more of the application, we can get up to 80% improvement in page performance.

SharePoint Branding

Implementing proper branding is crucial to Page Performance. The Branding Architect should re-visit the page components and ensure only required components are used in the page. Few of the items are listed below:

1. Do not use Web Part Zone, Content Editor etc. if there are not direct requirement

2. Remove unwanted SharePoint link & JS file references

If you are using Full Page Branding, it is better to start with a clean ASPX page and add the Minimal SharePoint components like JS Links, Form Digest etc.

This step should improve performance by 20%.

Offline Application Cache

If your users are using HTML5 Compatible Browsers, then Offline Application Cache is recommended. This will enable files to be cached in the browser side & reducing round trips.

Up to 80% Performance Improvement can be achieve using this step.

JS Bundling

JS Bundling is combining multiple JS files into a bundle file. This will reduce the number of Network calls to the server. The same can be applied to CSS Bundling as well.

This step should give up to 20% Improvement in Page Performance.

Image Spriting

Image Spriting is combining multiple image files into a single file. This will reduce the number of requests to the server.

This step should give up to 20% Improvement in Page Performance.

AJAX Cache Busting

There seems to be a big delay with Internet Explorer on REST API calls. This can be resolved through AJAX Cache Busting.

The idea here is to add a dynamic query parameter with date/timestamp so that each REST API URL will look unique and the browser will bypass Cache checking.

This should improve 20% in page performance.

JSOM Batching

If you are using multiple REST API calls, you may also consider using JSOM Batching. This can improve 20% in page performance.

image

The Browsers are using multi-threaded mode to fetch the files.

References

http://www.jeanpaulva.com/index.php/2015/12/02/cost-of-sharepoint-branding/

Summary

In this article we have explored few options to improve SharePoint Page Performance.

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