November 22, 2015 / Kannan / 0 Comments
There are many articles which explain how to setup the Remote Web & SharePoint On-Prem. The following articles explains everything end to end.
http://blogs.msdn.com/b/russmax/archive/2014/06/23/part-1-intro-to-provider-hosted-apps-setup-the-infrastructure.aspx
http://blogs.msdn.com/b/russmax/archive/2014/06/26/part-2-intro-to-provider-hosted-apps-develop-package-and-deploy.aspx
August 24, 2015 / Kannan / 1 Comment
Following is the JSOM code which will help in getting single or multiple items from a SharePoint’s People Picker Field.
function GetPeoplePickerFieldValue(currentListItem, internalFieldName) {
if (currentListItem.get_item(internalFieldName) !== 'undefined' && currentListItem.get_item(internalFieldName) !== null) {
if (currentListItem.get_item(internalFieldName).length > 0) {
var _user = "";
//If field has only one item
if (currentListItem.get_item(internalFieldName).length == 1) {
_user = currentListItem.get_item(internalFieldName)[0].get_lookupValue();
if (_user == null)
_user = "";
}
//If field has multiple item
if (currentListItem.get_item(internalFieldName).length > 1) {
for (var i = 0; i < currentListItem.get_item(internalFieldName).length; i++) {
//Append all User names with a semi colon separator
_user = _user + currentListItem.get_item(internalFieldName)[i].get_lookupValue() + "; ";
}
_user.trim;
if (_user == null)
_user = "";
}
}
return _user;
}
}
Source: Microsoft TechNet Forum
August 2, 2015 / Kannan / 0 Comments
Windows 10 is awesome and currently one of the feature which I like is, changing the task bar & start menu accent colour based on current wallpaper.
To invoke this, do the following.
- Right click on empty desktop
- Click “Personalize” menu item
- Select “Colours” tab
- Enable or toggle on “Automatically pick an accent colour from my background”
- Enable or toggle “Show colour on Start, taskbar and action centre”
- Optionally you can make Start Menu, taskbar & action centre transparent by toggling the last option.
July 6, 2015 / Kannan / 0 Comments
Recently I had a requirement where the user needed to copy an item’s URL to clipboard in SharePoint.
Using the SharePoint designer, I created a Custom Action and in the “Navigate to URL” action type I set the following.
javascript:clipboardData.setData("Text", window.location.protocol+'//'+window.location.hostname+':'+window.location.port +'/sites//Lists//DispForm.aspx?ID='+'{ItemId}');alert('Item URL \"'+window.location.protocol+'//'+window.location.hostname+':'+window.location.port +'/sites//Lists//DispForm.aspx?ID='+'{ItemId}'+'\" copied to clipboard');
November 15, 2014 / Kannan / 4 Comments
When I was trying to register Workflow Service with SharePoint 2013 Server, I was getting error “The root of the certificate chain is not a trusted root authority”.
The reason for this error is while registering the service we point to workflow site with https as shown below, this site has a certificate which the SharePoint server doesn’t trust.
Register-SPWorkflowService –SPSite “http://spapp/sites/dev/” –WorkflowHostUri “https://wfserver:12290/” –AllowOAuthHttp
There are 2 things to check.
- Check if the WorkflowHostUri is having a Fully Qualified Domain (FQD) instead of machine name.
- Check if the SharePoint server trusts the workflow site’s certificate
1. Use FQD. Hence instead of using machine name for WorkflowHostUri, use full domain name, like https://wfserver.domain.com:12290/
2. Make sure the SharePoint Server trusts the certificate of Workflow site. For that do the following
- In the server browse the site https://wfserver.domain.com:12290/ and check if you get Certificate trust error, if so proceed to next point
- Start Management Power Shell as Administrator in the workflow server and run the following 2 commands
- $rootCert = (Get-SPCertificateAuthority).RootCertificate
- $rootCert.Export(“Cert”) | Set-Content C:\SharePointRootAuthority.cer -Encoding byte
- Navigate to the SharePoint Server and open run or command prompt and type MMC and hit Enter. This will open Console1.
- In Console1 navigate to file in the ribbon menu and select “Add/Remove snap-in”
- Add “Certificates” to the right hand side and then click “OK”. You will prompted with the Certificates snap-in. I selected “Computer account”>Next>Local computer>Finish>OK
- Import the certificate “C:\SharePointRootAuthority.cer” into “Trusted root certification authority” location. You can complete this by right clicking on “Trusted root certification authority” and selecting All Tasks > Import
Source:
Microsoft MSDN Forum, EPM Partners
October 24, 2014 / Kannan / 0 Comments
The following table lists SharePoint 2013 Service Applications which can help in deciding which edition of SharePoint 2013 can be purchased based on the solution design and scenario.
SharePoint 2013 Service Application | Foundation | Standard | Enterprise | Office 365 |
---|
Access Services | | | | |
Access Services 2010 | | | | |
App Management Service | | | | |
Business Data Connectivity Service | | | | |
Excel Services Application | | | | |
Machine Translation Service | | | | |
PerformancePoint Service Application | | | | |
PowerPoint Automation Services | | | | |
Managed Metadata Service Application | | | | |
Search Service Application | | | | |
Secure Store Service | | | | |
Site Subscription Settings Service | | | | |
State Service | | | | |
User and Health Data Collection Service | | | | |
User Profile Service Application | | | | |
Visio Graphics Service | | | | |
Word Automation Services | | | | |
Work Management Service Application | | | | |
Workflow Service Application | | | | |
October 8, 2014 / Kannan / 0 Comments
Following is the list of new features & changes in SharePoint 2013 which I have gathered based on the glances through various sites and books.
Shredded Storage
- Reduces size of content database when storing file version
- Reduced size of content database helps in backup timelines
- Shredded storage optimizes network traffic between web server and SQL server by reducing the need to transfer the entire document
- Since only changes are sent back and forth between client and server, a document is available in Office Document Cache (ODC – a feature implemented in Office 2010) even when SharePoint server is offline
- User can start working on a document while it is downloading
- MS-FSSHTTP (File Sync via SOAP over HTTP) helps in optimized faster document transfers between MS Office client and SharePoint which improves usability of office applications when a user saves a version and continues editing while saved version is being uploaded to SharePoint (Note: This was already available in Office 2010/SharePoint 2010 and now has been improved)
- SharePoint 2013 now uses MS-FSSHTTP for document transfer not only between Client and SharePoint Server but now with SQL Server also.
SQL Improvements
- All Databases now conform to SQL Azure compliance criteria
- Redundant, unused tables and track links indices are removed
- I/O operations while browsing document libraries have been optimized
- Utilization of Sparse Columns (A feature implemented in SQL Server 2008) for wide list (Using rows for column data when max columns in a row sql is reached) has been reduced
Improvements on dependency of large list
Request Management
- Route HTTP requests to different servers based on specific workloads
- Recognize incoming request by looking into headers, request IP address or subnets
- Based on the incoming request, can prioritize by redirecting to another server or blocking that request etc.
- Request Management Rules can help route specific set of incoming request to specific set of servers. For example a rule might route a request which needs more processing to a server with high static (Identifies a server capability being powerful or weak) & health (Dynamic health of a server) weight
- If Catch All (*) rule is not implemented, SharePoint routes the request to the server which it thinks is healthy
Workflow
- A dedicated Workflow Manger Farm (Not installed by default and only utilized by SharePoint 2013 workflow and not SharePoint 2010/Legacy workflow) can offload the workflow processing from SharePoint Server improving SharePoint’s performance
Note: SharePoint 2013 workflow templates are not available by default as SharePoint 2013 still uses only 2010 templates. Hence to utilize Workflow Manager Farm, 2013 templates needs to be created
Caching
- SharePoint 2013 now uses distributed cache, hence each server in farm doesn’t need to fetch same content from DB for similar requests going to specific server. Instead they share that content across servers and hence roundtrip to content db from each server for same request is reduced
- Feeds, Search (Content Search Web Part) & Logon Tokens utilize distributed cache
UI
- Minimal Download Strategy (MDS) now helps in loading part of the page instead of whole page when content get’s changed
Note: MSD is not enabled for publishing sites and custom controls migrated from 2010 to 2013( Custom controls needs to be edited with MsdCompliantAttribute set and re-compiled)
SharePoint 2013 now uses HTML5 for themes.
Note: Since HTML5 is used as themes, creating one with Office applications to create themes is limited
- SharePoint 2013 has improvements in rendering content in Mobile environment
- Addition of geolocation field will help maintain location data in list column
- Contemporary view is used if Mobile supports HTML5 else Classic View is downloaded
Service Applications
- New Machine Translation Service uses bing to translate sites, files, pages and term sets
- New Workflow Management Service helps aggregate tasks from MS Exchange 2013, MS Project Server 2013 & MS SharePoint 2013 to user’s my-site with 2-way sync between them
- New App Management Service help manage new SharePoint Apps
- Search Service Application is now totally re-engineered based on SharePoint 2010 Enterprise Search and FAST Search and hence FAST search is no more a available
- All flavours of SharePoint 2013 (Foundation, Standard & Enterprise) use same search object model
- Managed Metadata Service now has properties for Tags and Tags can be pinned to avoid duplication
- Search Service Application now has inbuilt Web Analytics, and Web Analytics is no longer a separate service application
Office Web Apps
- This is now a separate product and separate license
- This will be installed on it’s own server in a farm and hence management/Scaling of either this or SharePoint is far more easier
Note: Viewing office documents in SharePoint 2013 doesn’t require Office Web Apps and respective license, but if editing is required then both are required
- Documents can be now viewed in full screen mode
- PowerPoint and Word now supports multi-authoring
- Search result in SharePoint can show a preview of office documents when Office Web Apps is available and user hovers over the link in the search result
Business Connectivity Service
- BCS now has an additional connection protocol which is OData
- Event Receivers for external data changes is a new feature
- External Content Type can be scoped to SharePoint Apps as opposed to Service Application level in SharePoint 2010
Access Service
- Access Service has been completely re-built
- Access Service 2010 is for sites built from Access web database definition
- Access Service now stores data in SQL Server 2012 and developers/advanced users can directly interact with SQL Server for more advance report generations
Authentication
- SharePoint 2013’s has extended claims based authentication utilizing OAuth 2.0 and dedicated server for STS authentication
- Because of this new extended auth, new scenarios are possible with MS Exchange 2013, MS Lync 2013, SharePoint App Store/App Catalogue and any other service supporting server to server auth protocol
- Claims is now recommended as opposed to classic in SharePoint 2010 due to new improved claims which didn’t work with People Picker and SSRS (2008 R2) in 2010
- Classic mode web applications can now be only created using PowerShell
- Additional Logging is now added to troubleshoot authentication issues
Web Applications
- Host Named site collections is the new recommendation instead of path based site collections but needs to be analysed before implementing as some extended and hosting in multiple web apps are not supported
- Document Workspace, All types of Meeting Workspace Template, Group Work & Personalization site templates have been removed but migration from 2010 to 2013 is allowed and will work in 2013
Development
- Everything now is an app. Be it a list, a library, a custom solution etc
- Apps now run isolated from SharePoint Server but integrated with SharePoint Server
- In addition to Farm & Sandboxed solutions, Extended Client Object model is new for code to run external applications
- Apps can be published and made available in on-premises or cloud based market places
- SharePoint Apps is now preferred instead of sandboxed solutions
July 11, 2014 / Kannan / 0 Comments
With the following Windows PowerShell Command, a managed account can be provided access to a content database.
$w = Get-SPWebApplication -identity http://<WebApplication>
$w.GrantAccessToProcessIdentity("<Domain>\<Username>")
Note: Before running this command, the account should be registered as managed account
To register a managed account
- On the SharePoint Central Administration website home page, in the left navigation, click Security.
- On the Security page, under General Security, click Configure managed accounts.
- On the Managed Accounts page, click Register Managed Account.
- Type the user name and password of the domain account that you are registering.
- Optionally, select the Enable automatic password change check box if you want SharePoint Server to manage password changes for this account.
- Click OK.
March 26, 2014 / Kannan / 2 Comments
WCF Service with SOAP, REST JSON & REST XML – 3 in 1 !
WCF has evolved a lot in the past few years. Currently expectations from end user are that, they should be able to use applications across multiple devices, be it Windows, Mac, mobile devices or web.
Service Oriented Architecture (SOA) is the right architecture when we have to deal with such a scenario. SOA helps multiple type of applications to consume and process data without the need to implement the back-end data access or business logics. Be it a Windows/OS-X desktops application or iOS/Android/Windows mobile applications.
In the case of Windows/ASP.NET web applications, web-service can expose SOAP based service which can be consumed and implemented easily using existing .NET frameworks.
For Mac applications REST as well SOAP can be consumed. Though SOAP consumption requires non traditional methods. With development tools like Xamarin it’s even easier.
For Mobile applications be it iOS based or Android based or Windows Mobile based or even Java based, they can consume REST based service in JSON/XML format and can be implemented easily.
Finally for web based applications we have Jquery which has direct support for JSON.
This post will explain how to enable all the three SOAP, REST JSON & REST XML in WCF Service along with a sample source code.
Let’s start by creating a WCF Service Application using Visual Studio and .NET Framework 4.5. You can use even Framework 4.0 or 3.5
Interface
Let’s modify interface so that operation contracts support REST Get and POST operations
- Set Attributes for each OperationContract (System.ServiceModel.Web.WebInvoke or System.ServiceModel.Web.WebGet) along with URI Template
[OperationContract]
[WebGet(UriTemplate = "/GetData/?value={value}")]//1. Added "WebGet" Attributes
string GetData(int value);
- For WebInvoke set Attribute with Method, UriTemplate & BodyStyle as Bare
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/GetDataUsingDataContract/", BodyStyle = WebMessageBodyStyle.Bare)]//2. Added "WebInvoke" Attribute with Method, UriTemplate & BodyStyle as Bare
CompositeType GetDataUsingDataContract(CompositeType composite);
Setting BodyStyle as Bare will allow the service to expect and respond with data type (json/xml) based on the “content-type: application/json or content-type: application/xml” which should be set as part of incoming request’s header.
Final Interface Code (Look into the highlighted lines)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace MixedWebService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface ITestService
{
[OperationContract]
[WebGet(UriTemplate = "/GetData/?value={value}")]//1. Added "WebGet" Attributes
string GetData(int value);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/GetDataUsingDataContract/", BodyStyle = WebMessageBodyStyle.Bare)]//2. Added "WebInvoke" Attribute with Method, UriTemplate & BodyStyle as Bare
CompositeType GetDataUsingDataContract(CompositeType composite);
// TODO: Add your service operations here
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}
[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
}
Web.Config
Let’s modify the web.config so that it can support both SOAP as well as REST and allow the service to auto select the REST request and response formats.
For SOAP, add service behavior with name “DefaultServiceBehavior“. This should be under <system.servicemodel><behaviors><serviceBehaviors>
<behavior name="DefaultServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
For REST, add endpoint behavior with name “RESTEndPointBehavior“. This should be under <system.servicemodel><behaviors><endpointBehaviors>
Make sure automaticFormatSelectionEnabled is set to true in webHttp tag. This will allow the service to expect and respond with data type (json/xml) based on the “content-type: application/json or content-type: application/xml” which should be set as part of incoming request’s header.
<behavior name="RESTEndPointBehavior">
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</behavior>
Finally add service under <system.servicemodel><services>
<service name="MixedWebService.TestService" behaviorConfiguration="DefaultServiceBehavior"><!--Added Service with DefaultServiceBehavior as behaviorConfiguration-->
<endpoint address="SoapService" binding="basicHttpBinding" contract="MixedWebService.ITestService"/><!--Added basicHttpBinding as SoapService-->
<endpoint address="RestService" binding="webHttpBinding" behaviorConfiguration="RESTEndPointBehavior" contract="MixedWebService.ITestService"/><!--Added webHttpBinding as RestService with RESTEndPointBehavior as behaviorConfiguration-->
</service>
The endpoint SoapService uses basicHttpBinding where as endpoint RestService uses webHttpBinding.
The RESTEndPointBehavior behavior configuration will make sure the service uses automatic format selection.
Hence when the incoming request’s header has “content-type: application/json”, the service will expect a json based request data and respond with json data. If it has “content-type: application/xml”, the service will expect a xml based request data and respond with xml data.
Final Web.config code (Look into the highlighted lines)
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="MixedWebService.TestService" behaviorConfiguration="DefaultServiceBehavior"><!--Added Service with DefaultServiceBehavior as behaviorConfiguration-->
<endpoint address="SoapService" binding="basicHttpBinding" contract="MixedWebService.ITestService"/><!--Added basicHttpBinding as SoapService-->
<endpoint address="RestService" binding="webHttpBinding" behaviorConfiguration="RESTEndPointBehavior" contract="MixedWebService.ITestService"/><!--Added webHttpBinding as RestService with RESTEndPointBehavior as behaviorConfiguration-->
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultServiceBehavior"><!--Added DefaultServiceBehavior referenced at service tag above-->
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="RESTEndPointBehavior"><!--Added RESTEndPointBehavior referenced at service tag above-->
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true"/><!--automaticFormatSelectionEnabled when set to true expects input and provides output based on the "content-type: application/json or content-type: application/xml" as part of incoming request's header. -->
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Now let’s look into the part where the hosted service can be consumed and see if it works fine.
SOAP:
Launch the WCF Test Client using Visual Studio Command Prompt
Add the service and call each methods with appropriate inputs. You should be able to see a result similar to below.
For REST we will use Fiddler to compose and analyze the request and response.
Launch the fiddler, use the screenshots below to compose a request. Make a note that content-type header decides the message format.
Also the URL should end with “RestService” then operation
e.g http://localhost:5469/TestService.svc/RestService/GetData/?value=1
REST GET using XML:
REST POST using XML:
REST GET using JSON:
REST POST using JSON:
Note: In all the above scenarios, the input and output use the same data format.