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 July, 2015

Update JS Link of Site using PowerShell

Posted by Paul on July 30, 2015

In this article we can explore how to update the JS Link of a Page using PowerShell.

Create Page

Open your SharePoint site and create a list from Tasks template.

image

Name it as My Tasks as shown below.

image

You will get the tasks list as shown below.

image

Copy the URL of the list. We will need it in next step.

http://server/Lists/My%20Tasks/AllItems.aspx

image

Please note that we require the %20 also to denote space character.

Copy HelloWorld.js

Now create a HelloWorld.js file and copy it to the Site Assets library.

image

Create PowerShell Script

Now you can open the PowerShell ISE editor and add the following code.

# Add Snapin

if ((Get-PSSnapin “Microsoft.SharePoint.PowerShell” -ErrorAction SilentlyContinue) -eq $null)

{

Add-PSSnapin “Microsoft.SharePoint.PowerShell”

}

# Update Page

$web = Get-SPWeb http://sharepoint

$page = “/Lists/My%20Tasks/AllItems.aspx”

$file = $web.GetFile($page)

$file.CheckOut();

$manager = $web.GetLimitedWebPartManager($page, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

$webpart = $manager.WebParts[0]

$webpart.JSLink = “/siteassets/helloworld.js”

$manager.SaveChanges($webpart);

$file.CheckIn(“JS Link updated”);

Change the Server URL appropriately & Run the code. If the code executed successfully, you got your page updated.

Verification

You can verify the page update by opening page in edit mode. Go to the web part properties and you can see the JS link got updated there.
image

This concludes JS Link updating using PowerShell.
image

Please note that the preferred way of update is using CSOM code. In this way we can use the same code base for both SharePoint On-Premise & Online.

References

https://code.msdn.microsoft.com/office/Client-side-rendering-JS-2ed3538a

Summary

In this article we have explored how to update the JS Link of Site using PowerShell. You can get the code as attachment.

Advertisements

Posted in SharePoint, SharePoint 2013 | Leave a Comment »

Enable SharePoint Designer

Posted by Paul on July 24, 2015

In this post we can explore how to enable SharePoint Designer for a site collection.

SharePoint Designer

SharePoint Designer can be locked due to multiple reasons. But, SharePoint Designer is required to customize pages, create custom workflows & lot of other quick tasks.

If you are the Site Collection Administrator, you can enable SharePoint Designer as following.

Open Site Settings Gear > Site Contents menu item.

image

Click on the SharePoint Designer Settings link.

image

You can click on the Enable SharePoint Designer checkbox item as shown below.

image

image

If you cannot see the above option, you might need to check with Central Administration level for enabling the option.

Summary

In this post we have explored how to enable SharePoint Designer for a site collection.

Posted in SharePoint, SharePoint 2013 | Leave a Comment »

SharePoint PnP

Posted by Paul on July 21, 2015

In this post I would like to introduce you another great resource site by Microsoft Professionals.

SharePoint PnP – Patterns & Practices

http://dev.office.com/patterns-and-practices

image

About PnP

The Patterns and Practices was formed by Microsoft Consultants to share their Migration effort to O365.

image

Guidance

Following are the guidance  areas which PnP are advantageous to the SharePoint community.

  1. Customize UI using JavaScript
  2. Site Collection Provisioning using CSOM
  3. Branding
  4. Provisioning in Hybrid Environments

image

Posted in Uncategorized | Leave a Comment »

SharePoint Online Compatible Deployment

Posted by Paul on July 20, 2015

In this article I would like to inform on the SharePoint Online Compatible Deployment tools and techniques.

Normal Deployment

To understand the difference of SharePoint Online Compatible Deployment, let us refer back to our normal Farm Solution deployment.

1. We create a Farm Solution in Visual Studio

2. Add site pages to the solution

3. Add web parts

4. Create custom lists & libraries

5. Package the solution

6. Deploy the WSP to SharePoint Farm

The last step would induce a problem! SharePoint Online does not allow Farm Solution Deployment. Now we have to think about an alternative solution?

Alternative Deployment

Following are the options used for SharePoint Online deployment.

1. Remote Provisioning

2. App Installation

3. PowerShell Online

Remote Provisioning

Among these methods, Remote Provisioning is gaining speed due to following advantages:

1. Allows configuration of Site Collection, Site, List, Libraries

2. Reusable for both SharePoint On-Premise & Online versions

3. No site definitions Or server-side code involved

4. Preferred use of CSOM code

Remote Provisioning can be applied in following cases:

1. One time configuration (site provisioning is done during installation process)

2. Multiple time configuration (where new site provisioning is invoked by user)

image

Tools

Following are the Tools available:

1. SharePoint PnP

2. Custom CSOM Console Application

SharePoint PnP (Patterns & Practices) contains sample code for Remote Site Provisioning. For further control on provisioning, I would recommend creating your own Custom CSOM Console Application.

Even for SharePoint On-Premise solutions, the above SharePoint Online Compatible Deployment is recommended as it can help a lot in future migration to SharePoint Online.

References

http://dev.office.com/patterns-and-practices-detail/1938

Summary

In this article we have explored the SharePoint Online Compatible Deployment tools & techniques.

Posted in SharePoint, SharePoint 2013 | Leave a Comment »

SharePoint Online Compatible Development Strategy

Posted by Paul on July 16, 2015

In this article I would like to summarize the SharePoint Online Compatible Development Strategy which is picking speed in high profile organizations and also endorse by Microsoft.

image

Scalability

SharePoint Online provides easier Scalability compared with SharePoint On-Premises. But, the Data Security, Access while No-Internet are additional factors to be considered while moving to SharePoint Online.

CSOM

As denoted earlier, Client-Side Object Model is the preferred programming way for SharePoint Online. CSOM frees the server from running custom code.

For complex coding or legacy systems, PHA approach can be added. In PHA (Provider-Hosted-App) the code resides in a different server. Here we can use C# CSOM methods.

REST

REST Services are the preferred approach for performing CRUD operations. If the solution requires custom business logic processing, additional WCF services can be used.

REST is preferred approach while using Client side scripting.

OData

OData allows custom field filtering over results. Additionally, it allows sorting, paging operations too. REST combined with OData should cover the core business solution requirements.

No Custom Master Pages

Custom Master Pages are not preferred in the SharePoint Online Compatible Development strategy. In the SharePoint Online version, using custom master pages prevents the page from automatic master page updates.

SharePoint Composed Looks & Themes framework can be used to support basic functionalities of a custom master page. For advanced customizations, following approaches are preffered.

JavaScript Injection during pre-render of pages through the JS Link option is one preferred approach without using custom master pages.

Branding for Publishing Sites

Usually the publishing sites has to undergo Branding. Identifying these customer facing sites and applying customizations only to these will save lot of effort from development, implementation & maintenance.

No Branding on Collaboration Sites

Collaboration Sites are usually meant for Internal Team Activities and can be freed from branding.

Client Side Rendering

Client Side Rendering allows modifying the list items and field look & feel. Here JavaScript injection controls the pre-render event of list items and thus client side rendering is performed. We can use the JS Link option here too.

Deployment

If we are using Farm Solutions or WSP deployment, the same may not work with SharePoint Online. In this case the preferred deployment approach is to use a CSOM Deployment Tool which will do the custom deployment activities like:

1. Creation of site collection, sites

2. Configure content types

3. Configure site columns

4. Configure list & libraries

5. Configure Permissions

image

Please refer the references for more information.

References

http://www.jeanpaulva.com/index.php/2015/07/09/no-master-pages/

http://www.jeanpaulva.com/index.php/2015/07/12/client-side-rendering-csr/

https://code.msdn.microsoft.com/office/Client-side-rendering-JS-2ed3538a

Summary

In this article we have explored the SharePoint Online Compatible Development Strategies. I believe these ideas would require additional efforts in the short-run to save custom essay writing the extra-additional efforts I the long-run.

Posted in SharePoint, SharePoint 2013 | Leave a Comment »

Why Master Pages are not recommended?

Posted by Paul on July 15, 2015

In this article we can explore the reasons of No Master Pages.

SharePoint Online

Please note that we are talking about SharePoint Online context. In the case of SharePoint Online, Microsoft will be pushing updates to existing master pages.

So in this case, if you are using custom master pages, you won’t get the new updates. This will make your page act isolated from the rest.

Thus the recommended approach is to use existing master pages in SharePoint Online. You can use JavaScript Injection to update the page sections for Branding or Common Behavior.

image

SharePoint On-Premise

Take a note that, the above practice is recommended for SharePoint On-Premise too. The reason is that, in future if the SharePoint solution is migrated to SharePoint Online, there will be least code changes required.

If we were using custom master pages, then during the upgrade time we have to remove the custom master pages and create JS injection pattern. This will be additional cost in the future.

image

You can find more on the Patterns recommended for SharePoint Online using the References link.

References

https://channel9.msdn.com/Blogs/Office-365-Dev/JavaScript-injection-in-SharePoint-Online-Office-365-Developer-Patterns-and-Practices

Summary

In this post we have explored the reason for No Master Pages. Although the pattern is recommended for SharePoint Online, this has been adapter to SharePoint On-Premise solutions as well.

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

Client Side Rendering (CSR)

Posted by Paul on July 12, 2015

SharePoint 2013 is seeing more and more practice of CSR (Client Side Rendering)

Client Side Rendering

Client Side Rendering enables customizations from the client-side on:

  1. List Views
  2. List Items
  3. Add Forms
  4. Edit Forms
  5. Web Parts

Why Client Side Rendering?

Client Side Rendering is compatible with:

  1. SharePoint Online
  2. SharePoint On-Premise

This makes us use the same solution work in SharePoint On-Premise & Online.

How it works?

We can attach a JavaScript code to the page using JS Link.  The code carries out customization operation of page controls like list views, list items etc.

The JS code will inject into respective event handlers.  As the code is invoked during pre-render, we won’t see any flickering.

What are the applications?

Following are some of the CSR examples:

CSR Accordion:

image

CSR Progress bar:

image

Custom Form Controls

image

References

You can find more examples at:

https://code.msdn.microsoft.com/office/Client-side-rendering-JS-2ed3538a

Summary

In this post we have seen an overview of CSR (Client Side Rendering)

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

No Master Pages!

Posted by Paul on July 9, 2015

You will get shocked like me when you hear:

“No custom master pages!”

for your SharePoint project.

Yes! It is the case

In the real-worlds scenarios with high-quality standards: Yes! It is the case.

Why no custom master pages?

You can find the following link for more details.

http://www.jeanpaulva.com/index.php/2015/07/15/why-master-pages-are-not-recommended/

image

Microsoft Recommendation

Now obviously you will ask: How to replace master pages?

Replacing Master Pages

Master Pages are replaced with the combination of following:

  1. Use Composed Looks for managing themes
    1. Use JavaScript Injection to update UI sections

image

Note

This also aligns with the Client-side rendering strategy.

References

https://msdn.microsoft.com/en-us/library/office/Dn913116.aspx

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

Minimal Download Strategy

Posted by Paul on July 5, 2015

In this article we can explore about Minimal Download Strategy of SharePoint 2013.

Minimal Download Strategy

This is a technique used to optimize page rendering. We need to activate the site feature Minimal Download Strategy to achieve this.

When this feature is activated, only the changes between pages will be send back to the browser. Following are the pages involved:

· Current Page

· Requested Page

Feature Activation

You can activate this feature from Site > Settings > Manage Site Features page.

image

URL

Once the feature is activated, the URL gets changed.

image

You can see all the pages will be using start.aspx for rendering.

The requested page will be passed after the #.

Advantages

Following are the advantages of using MDS:

1. Speed Pages will load faster.

2. Less Bandwidth Less bandwidth will be used – good for tablets/mobiles with metered/slow connections.

How it works?

There are 2 components that enable MDS:

1. Server side

2. Client side

Each page will be divided into multiple sections.

When a client requests a new page, the serve calculates the delta (changes). Only the changed sections will be sent to client. The client will be smart enough to patch the received sections to appropriate sections.

image

By default MDS feature is activated.

References

https://msdn.microsoft.com/library/office/dn456544(v=office.15).aspx

Summary

In this article we have explored about Minimal Download Strategy. Now this also answers why the start.aspx is doing in SharePoint 2013.

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

OData substringof Examples

Posted by Paul on July 3, 2015

In this article we can explore OData examples for string method substring.

substringof

This filter returns the field values containing specified string.

Please note that the method-name is case sensitive & only lower case works.

Example

Please create the data as shown below.

image

Following is the query URL.

http://sharepoint/_api/Web/Lists/GetByTitle(‘Contacts’)/Items?$filter=substringof(‘avv’,Title)

Following is the result using Chrome browser.

image

image

Please note that we are querying against column named Title. The column name appears second after the value.

More Examples

You can now try a non-existing string.

Following is the URL:

http://sharepoint/_api/Web/Lists/GetByTitle(‘Contacts’)/Items?$filter=substringof(‘ABC’,%20Title)

The result is empty XML packet.

image

image

Please note that the operation name should be in lower-case.

References

https://msdn.microsoft.com/en-us/library/gg309461.aspx

Summary

In this article we have explored OData examples for string method substring.

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