Showing posts with label SharePoint 2013. Show all posts
Showing posts with label SharePoint 2013. Show all posts

Friday, 12 August 2016

Creating Power Apps with SharePoint on-premises data


Power Apps now supports creating an app from data stored in lists on a SharePoint 2013 and SharePoint 2016 on-premises site.

Below are the steps for creating a Power App based on on-premises data

1.      From the Power Apps studio  click New from the left navigation bar.

2.      Under “Create app from your data” select SharePoint.

3.      In the next screen select “Connect using on-premises data gateway” to connect to SharePoint on-premises.


4.      This would display additional fields for connection details.


5.      From the Authentication Type drop down choose your authentication type. Currently Windows and Basic authentication are supported for SharePoint on-premises.

6.      Provide user name and password for the connection.

7.      A gateway is required for creating an on-premises connection. If you don’t already have a gateway, you can create one by following the details listed here.

8.      Click “Connect” button to create the connection.

9.      In the connect to SharePoint site page enter the URL of SharePoint on-premises site and click Go


10.  This would display lists within the site. Select the list based on which you want to create the Power App and click Connect.

11.  The App screens with the fields form the list you had selected will be created.

12.  You can make required changes to the field and layout and save the App.

Note:

When you share a Power App that uses SharePoint on-premises connection, the gateway used by the SharePoint connection will also be shared implicitly.

Thursday, 16 June 2016

June 2016 CU for SharePoint Server 2013 adds Cloud Hybrid Search capability to SharePoint 2013

The June 2016 Cumulative Update for SharePoint Server 2013 which was released on June 14, 2016 adds Cloud Hybrid Search capability to SharePoint 2013. By using cloud hybrid search all crawled content including on-premises content is indexed in search index that resides in Office 365 SharePoint Online. When users perform a search the get results from both on-premises and Office 365 content.


To know more details about the June 2016 CU for SharePoint 2013 visit https://support.microsoft.com/en-us/kb/3115174

Thursday, 28 April 2016

Edge browser now supports Drag and Drop and Export to Excel in SharePoint Document Libraries


When Edge browser was released with Windows 10, it came with few limitations when working with SharePoint. The limitations are listed in the KB article https://support.microsoft.com/en-us/kb/3083635 and the suggested work around was to use Internet Explorer. With the second publish release of Edge Browser that came with November 2015 Windows 10 update (version 25.10586) , Drag and drop of documents and Export to Excel are supported for SharePoint document libraries.

Tuesday, 12 April 2016

PNP Responsive UI Package for On-Premise SharePoint 2013 and 2016


Last month the SharePoint Patterns and Practices (PnP) group released the Responsive UI Package for SharePoint, a solution that makes SharePoint 2013 and SharePoint 2016 sites more responsive in tablets and mobile phones.  The solution uses JavaScript embed pattern to embed the styles and scripts to the site without making changes to master pages.

Installing the Responsive UI Package

1.      Before installing the Responsive UI Package, the below prerequisites have to be setup

a.      SharePoint 2016 or SharePoint 2013 with SP1 and April 2015 CU

b.      Download and install Office 365 Dev PNP commands from GitHub

2.      Download the Responsive UI Package zip file from GitHub and unzip them in a folder on SharePoint server

3.      Open PowerShell and navigate to the folder where the Responsive UI package files are unzipped.

4.      Then execute the Enable-SPResponsiveUI cmdlet against the site collection which you want to be responsive. The command takes 3 parameters

a.       TargetSiteUrl -  The URL of the Site Collection, where the Responsive UI will be enabled. for example: http://mysharepointintranet.com/sites/Site1

b.      InfrastructureSiteUrl - Is an optional parameter, which specifies the URL of Site Collection, where the JavaScript and CSS files used by Responsive UI solution will be uploaded.

c.       Credentials – Is the user credentials that will be used to authenticate against both the target Site Collection and infrastructure Site Collection and should be the credentials of a user with Site Collection Administrator rights. If the parameter isn’t provided PowerShell will prompt for credentials.

Example syntax: Enable-SPResponsiveUI.ps1 -TargetSiteUrl "https://mysharepointintranet.com/sites/site1"

5.      Executing  Enable-SPResponsiveUI cmdlet  will install the Responsive Package to the target site and if successful will display Responsive UI application succeeded in green font.

6.      The responsive UI Supports 3 rendering modes, desktop, tablet and smart phone. Below screenshots shows how the default SharePoint 2016 UI renders in these modes after Responsive UI Package is installed for a site collection.

Desktop Rendering




Tablet Rendering

Mobile Rendering

7.      To deactivate the Responsive UI, execute the Disable-SPResponsiveUI cmdlet by passing TargetSiteURL and Credentials parameters.

Monday, 31 August 2015

SharePoint 2013 and SharePoint 2016 Preview limitations in Edge browser

SharePoint 2013 and SharePoint 2016 Preview has limitations when accessed from Edge the latest and fastest browser from Microsoft that comes with Windows 10. Below are some of the functionality that will not work in SharePoint 2013 and SharePoint 2016 preview when using Edge browser

Drag and Drop for file upload
Files can’t be uploaded to libraries using Drag and Drop. When you try to do so, a not supported icon would be displayed

  
Features that require ActiveX components
Some features in SharePoint require ActiveX components and will not work in Edge browser. These features include Open with Explorer, Open with Access, Open with Project. These options would be disabled on the list\library ribbon



Customize in InfoPath
Clicking Customize in InfoPath from the ribbon would say that you’ll need Internet explorer to use the feature.


Export to Excel will show a warning
Clicking Export to Excel from the ribbon will show a warning stating that you will require compatible application, however the functionality will work.

 
Lync Contact Card
If the user has Lync\skype for business client installed on their machine and they hover over user name in SharePoint, the Lync Contact Card pops up showing information such as email, phone etc. This functionality depends on Active X and doesn’t work with Edge browser.

Thursday, 13 August 2015

Visual Studio 2015 Office Developer Tools automatically adds correct version of SharePoint client DLLs based on target SharePoint version


I recently installed Visual Studio 2015 and selected the Office developer tools feature as part of the install. Then I went about creating a sample SharePoint App project. The project creation wizard started with asking for SharePoint site and type of App

Next step required to specify the target SharePoint version. This step is newly added in Visual Studio 2015 and the target SharePoint version is auto selected based on the URL of the SharePoint site mentioned in previous step

As described  in the step Visual Studio 2015 Office Developer Tools adds correct reference to version SharePoint client DLL based on target SharePoint version.

If SharePoint 2013 was selected for target version then visual studio adds reference to version 15.0.0.0 of SharePoint.Client DLL

If SharePoint online was selected for target version then visual studio adds reference to version 16.1.3912.1204 of SharePoint.Client DLL

Friday, 31 July 2015

Could not load the assembly 'Microsoft.SharePoint,Version=16.0.0.0’ error when moving sites from Office 365 SharePoint Online to On Premise SharePoint 2013


Recently one of my clients who were using Office 365 SharePoint Online wanted to have a backup of their sites in their on-premise SharePoint environment. I used a leading SharePoint migration tool and was able to back up the sites to on premise SharePoint. But when trying to open a site or a document library I ran into the error “Could not load the assembly 'Microsoft.SharePoint,Version=16.0.0.0’”

The issue happened because Office 365 SharePoint Online is has been updated to version 16 of SharePoint DLL while the on-premise SharePoint 2013 server had version 15 of the DLL. All the pages for sites, libraries and lists were pointing to the version 16 of the DLL.

 If it was single page a quick fix would have been to open the page in SharePoint Designer and change the version of DLL to 15. But since there were many sites and sub sites with lots of libraries and list I wrote a PowerShell script(courtesy http://www.sharepointdiary.com/2013/02/create-update-copy-delete-views-powershell.html) to create new views for all lists and libraries and make them as default views. As the new view pages are referencing version 15 of Sharepoint the sites and libraries sprang back to life.
 


Friday, 17 April 2015

Setting the content type of a document uploaded to SharePoint Library through CSOM

There might be times when we will have to specify a content type for a file that is programmatically uploaded to a SharePoint library through CSOM. This blog post explains the steps involved in setting the custom content type through CSOM code. In order to set the content type we will be using the ParseAndSetFieldValue method of the list item and set the id of our desired content type to the ContentTypeId property.

The first step is to get the content type if of our content type. This is done by looping through all the content types attached to the library and getting the id of the particular content type.

string serverUrl = "SharePoint Site URL";

     String login = "user name";

            String password = "password";

            string listUrlName = "Library Name";

            string customcontenttypename = "Content Type Name";
 

            ClientContext context = new ClientContext(serverUrl);

           
               var passWord = new SecureString();

                foreach (char c in password.ToCharArray()) passWord.AppendChar(c);

                context.Credentials = new SharePointOnlineCredentials(login, passWord);

           List splist = context.Web.GetList(listUrlName);

             context.Load(splist);

             context.Load(splist.ContentTypes);

             context.ExecuteQuery();

              ContentType ctcustom = null;

foreach (ContentType ct in splist.ContentTypes)

{

if (ct.Name == customcontenttypename)

{
ctcustom = ct;

                               break;
}

}

Then we upload the file to the library

var folder = context.Web.GetFolderByServerRelativeUrl(listUrlName);

context.Load(folder);

var files = folder.Files;

context.Load(files);

       string filepath = @"File Path";

                  
       FileInfo fi = new FileInfo(filepath);

       var fci = new FileCreationInformation

{

Url = fi.Name,

Overwrite = true,

Content = System.IO.File.ReadAllBytes(filepath)
};

 
var file = files.Add(fci);
 
And then we set the content type of our custom content type to ContentTypeId property of the list item attached to the uploaded file

file.ListItemAllFields.ParseAndSetFieldValue("ContentTypeId", ctcustom.Id.ToString());

file.ListItemAllFields.Update();

context.Load(file);  

context.ExecuteQuery();

Thursday, 19 February 2015

Setting AlternateCSS URL of SharePoint site from CSOM


With the improvements made to SharePoint client side API  it is possible to update the Alternate CSS property of SPWeb from CSOM code. The property can be updated from .Net CSOM client or from JS or REST. For example to set the alternate CSS from JavaScript,  the following script can be added to a Script Editor  web part on any page in the SharePoint site  in which we want to apply alternate CSS style.
<script>
var clientContext;
var website;

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', OnReady);

function OnReady() {
    clientContext = SP.ClientContext.get_current();
    website = clientContext.get_web();
    website.set_alternateCssUrl('SiteAssets/test.css');
website.update();
    clientContext.executeQueryAsync(OnUpdateSucceeded, onUpdateFailed);
}

function OnUpdateSucceeded () {
}

function onUpdateFailed (sender, args) {
    alert('Error in update ' + args.get_message());
}

</script>
The latest versions CSOM SDK can be downloaded from SharePoint Server 2013 Client Components SDK or SharePoint Online Client Components SDK

Thursday, 16 October 2014

SharePoint 2013 custom BCS Connector


SharePoint 2013 provides out of the box BCS connectors for Database, WCF, .Net and OData sources. If you need to connect to other form of data like a XML file or a file system then a custom BCS Connector has to be developed.

This blog post will explain the steps involved in creating a Custom BCS connector for SharePoint 2013 that connects to a XML file source. The steps involved  are
Developing Custom Connector Assembly
Creating the BCS model
Deploying the assembly and model
Creating external lists using custom connector

Developing Custom Connector Assembly
The customer connector assembly should have a class that implements the ISystemUtility interface from in Microsoft.BusinessData assembly. ISystemUtility interface provides functionality to execute operations against the external system. ExecuteStatic  method is the most important method within the interface where  we will be implementing CRUD actions for the custom connector.

The first parameter in ExecuStatic method is of type ImethodInstance and has a property called MethodInstanceType which indicates the type of method that is being called against the external content.  Finder MethodInstanceType  corresponds to retrieving  all items and SpecificFinder corresponds to retrieving a particular item.

The third parameter is an object array that has items that can be used with MethodInstanceType. The last item in the array is reserved for the return parameter.

Below is the execute static method for XML connector

public void ExecuteStatic(IMethodInstance mi,
            ILobSystemInstance si,
            object[] args,
            IExecutionContext context)
        {
              
           switch (mi.MethodInstanceType)
            {
                    //Single product view
               case MethodInstanceType.SpecificFinder:
                    int id = (int)args[0];
                    args[1] = GetProduct(id);
                    break;
                    //Product Listing
                case MethodInstanceType.Finder:
                    args[args.Length - 1] = GetProducts();
                     break;    
            }

        }
GetProducts method has the logic for retrieving all products from the XML file and GetProduct method has the logic for retrieving a particular product within the XML file. Sign the custom connector assembly with a strong name and generate the dll.

Creating the BCS model
The BCS model file can be created using a XML editor or using Visual Studio. The BCS model XML file has the below elements

LOB System
LOB System Instance
Entities

The Lob System element has the SystemUtilityTypeName property where we specify the fully qualified name of our custom connector assembly. Below is an example snippet of LOB System element
      <Properties>
        <Property Type="System.String" Name="SystemUtilityTypeName">
XMLFileConnectorG.Connector, XMLFileConnectorG, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3c36ccc14bfdf0d2
</Property>
      </Properties>

LObSystemInstance elements is where we can specify properties that can be used in custom connector assembly code. For example we can add a property to take the path of external XML source data file
<LobSystemInstances>
        <LobSystemInstance Name="ItemsData">
          <Properties>
            <Property Name="xmlfilepath" Type="System.String">c:\testfolder\products.xml</Property>
         </Properties>
        </LobSystemInstance>
      </LobSystemInstances>

Entity element section is where the identifier, fields and methods of our external content type is defined. Below is the snippet for an entity by name item with Finder and Specific Finder methods
<Entity Name="Item" EstimatedInstanceCount="1000" Version="1.0.0.0" Namespace="XMLFileConnectorG">
          <Identifiers>
            <Identifier Name="Id" TypeName="System.Int32" />
          </Identifiers>
          <Methods>
            <Method Name="ItemFind">
              <Parameters>
                <Parameter Name="id" Direction="In">
                  <TypeDescriptor Name="id" TypeName="System.Int32" IdentifierName="Id" />
                </Parameter>
                <Parameter Name="Item" Direction="Return">
                  <TypeDescriptor Name="Item" TypeName="Microsoft.BusinessData.Runtime.DynamicType">
                    <TypeDescriptors>
                      <TypeDescriptor Name="Id" TypeName="System.Int32" IdentifierName="Id" />
                      <TypeDescriptor Name="Title" TypeName="System.String"/>
                     <TypeDescriptor Name="Category" TypeName="System.String"/>
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
              </Parameters>
              <MethodInstances>
                <MethodInstance Type="SpecificFinder"
                                Name="ItemSpecificFinder"
                                Default="true"
                                ReturnTypeDescriptorLevel="0"
                                ReturnParameterName="Item">
                </MethodInstance>
              </MethodInstances>
            </Method>
            <Method Name="ItemDataFinder">
              <Parameters>
                <Parameter Name="Items" Direction="Return">
                  <TypeDescriptor TypeName="Microsoft.BusinessData.Runtime.DynamicType[]" IsCollection="true" Name="Items">
                    <TypeDescriptors>
                      <TypeDescriptor Name="Item" TypeName="Microsoft.BusinessData.Runtime.DynamicType">
                        <TypeDescriptors>
                          <TypeDescriptor Name="Id" TypeName="System.String" IdentifierName="Id" />
                          <TypeDescriptor Name="Title" TypeName="System.String"/>
                          <TypeDescriptor Name="Category" TypeName="System.String"/>
                          </TypeDescriptors>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
              </Parameters>
              <MethodInstances>
                <MethodInstance Type="Finder"
                                Name="ItemFinder"
                                Default="true"
                                ReturnTypeDescriptorLevel="0"
                                ReturnParameterName="Items">
                </MethodInstance>
              </MethodInstances>
            </Method>
          </Methods>
        </Entity>

Deploying the assembly and model
The custom BCS connector assembly has to be installed to Global Assembly cache on the SharePoint 2013 server and the BCS Connector model has to be imported before we can create content type from our model.

The custom connector assembly can be installed on the SharePoint server by using gacutil utility or by just dragging and dropping the assembly file to C:\windows\assemby folder.

To import the BCS model to SharePoint 2013 copy the BCS model file has to be copied to a location in SharePoint 2013 server and below steps have to be performed
1.       Logon to SharePoint 2013 central administration site

2.       Select Manage service application under Application Management

3.       Click BCS service application

4.       Click the Edit tab and click Import on BDC models ribbon

5.       In the Import BDC model page select the BCS your model file

6.       In File Type, select model option.

7.       In Advanced Settings, check Localized names, Properties, and Permissions check boxes.

8.       Click Import button.

The BCS model will be imported and the page will display all available models as shown below

 

 Clicking the model will show the external content types available in it.


 Clicking on the external content type will show details about the content type


Creating external lists using custom connector
Once we have installed the assembly and imported the BCS model, we can create external lists from the external content type by performing the below steps

1.       Navigate to the SharePoint site where the external site has to be created

2.       Click on Settings Icon from top left and click View Site Content menu

3.       On the Site Contents page click Add and app icon

4.       On the Your Apps page search for external list and click on External List from the result

5.       On the Add External List pop up give a name for the external list and select the external content type that was imported.

6.       External list will be created and content from the XML file will be populated