Wednesday, April 30, 2014

How to Get Current Logged in User and Display Name using SharePoint 2013 REST API?

In this post we will discuss how to get current logged in user and display name using SharePoint 2013 REST API.

Also you can check out:

- Prevent new sites to be added to content databases in SharePoint 2013

- Steps to create App Catalog site in SharePoint 2013

- SharePoint 2013 list column status wise Change row Color using jQuery

REST API is quite simple and straightforward, used User ID to get user Title, Email for SharePoint 2013 and apps for SharePoint. use  /_api/web/getuserbyid(ID) to get the user field  in the response data, we have an “AuthorId” will get us the user Title, Email etc .


Step-1: Navigate to your SharePoint 2013 site and create a Wiki Page or a Web Parts page.

Step-2: The process to add your JavaScript code is quite straightforward:
Edit the page, go to the “Insert” tab in the Ribbon and click the “Web Part” option. In the “Web Parts” picker area, go to the “Media and Content” category, select the “Script Editor” Web Part and press the “Add button”.

Step-3: Once the Web Part is inserted into the page, you will see an “EDIT SNIPPET” link click. You can insert the HTML and/or JavaScript code into the dialog.


<script src="/Style Library/scripts/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
  var userid= _spPageContextInfo.userId;
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
var requestHeaders = { "accept" : "application/json;odata=verbose" };
$.ajax({
    url : requestUri,
    contentType : "application/json;odata=verbose",
    headers : requestHeaders,
    success : onSuccess,
    error : onError
});

function onSuccess(data, request){
    var Logg = data.d;

    //get login name
    var loginName  = Logg.LoginName.split('|')[1];
    alert(loginName);   
    //get display name
    alert(Logg.Title);

}

function onError(error) {
    alert("error");
}

</script>

In the code above, we'll get the author id from the list. By passing the author id in to GetUserBuId() method, it will return the user in raw format like "I:O#.f|xxxx|xx@xxxx.com". We can get the login name by splitting the output.


Tuesday, April 29, 2014

Prevent new sites to be added to content databases in SharePoint 2013

In this post we will discuss how we can prevent new sites to be added to content databases that grows more in database size.

Also you can check out:

- What happen when you press F5 in Visual Studio in SharePoint 2013?

- Create new site group in SharePoint 2013

- Create Apps using Office 365 development tools Napa

Suppose the content databases have grown larger than 100 gigabytes (GB). Large content databases can be difficult to back up and restore. And sometimes this causes the application to stop responding when you perform operations that affect entire databases.

Here we can edit the rule definition to prevent new sites from being added to these databases.

We can do this from SharePoint Central Administration.

Open SharePoint Central Administration, On the Monitoring page, in the Health Analyzer section, click Review rule definitions.

Then On the Health Analyzer Rule Definitions page, in the Availability category, click the name of the rule.

In the Health Analyzer Rule Definitions dialog box, click Edit Item, and then select the Repair Automatically check box.

Click Save. You can no longer add new sites to databases that exceed 100 GB.


Move Site Collections to other content databases in SharePoint 2013

In this post we will discuss how to move site collections to other content databases in SharePoint 2013. Also you can check out:

- Add user to group in SharePoint 2013

- New actions in SharePoint designer 2013 workflow: Call Web Service Action and Start workflow action

- Hide search box in home page in SharePoint 2013

There might have situation where we need to move site collections to different content database. Suppose the content database grows very large in size (More than 100 GB) then we need to move the site collection to different content data base.

We can move site collection by using PowerShell commands.

But before moving we need to make sure:

- The destination content database must already exist.

- The source content database and destination content database must be located on the same instance of SQL Server.

- The source content database and destination content database must be attached to the same web application.

PowerShell command:

Below is the PowerShell command to move a single site collection:

First Open SharePoint 2013 Management Shell and then run the below command.

Move-SPSite <http://SiteURL> -DestinationDatabase <DestinationContentDataBaseName>

Here <http://SiteURL> is the name of the site collection.

<DestinationContentDataBaseName>  is the name of the destination content database.

PowerShell command to move multiple site collections:

Get-SPSite -ContentDatabase <SourceContentDb> | Move-SPSite -DestinationDatabase <DestinationContentDb>

Here <SourceContentDb> is the name of the original content database.

<DestinationContentDb> is the name of the destination content database.


Saturday, April 26, 2014

InfoPath Forms Services forms cannot be filled out in a Web browser because no State Service connection is configured error in SharePoint 2013

Sometimes you will get this issue, InfoPath Forms Services forms cannot be filled out in a Web browser because no State Service connection is configured. In this post we will discuss how to resolve this.

Also you can check out:

- Architectural changes in SharePoint 2013

- 5 Pillars of SharePoint 2013

- Steps to create document library in SharePoint 2013

We can configure the state service connection from Central Administration.

Open SharePoint 2013 Central Administration, then from the home page click on Configuration Wizards.

On the Configuration Wizards page, under Farm Configuration, click Launch Farm Configuration Wizard.

On the Configure your Farm page, click Start the Wizard.

Then in the next page select State Service check box. And then click on OK.

This will create the state service.

Then we need to associate the state service to the web application.

To do this in Central Administration, on the home page, under Application Management, click Manage web applications.

On the Web Applications page, click the Web application for which you want to configure a service connection, and then click Service Connections on the ribbon.

In the Configure Service Application Associations dialog box, ensure that the State Service check box is selected, and then click OK.


InfoPath form library forms cannot be filled out in a Web browser error in SharePoint 2013

In this post we will discuss how to resolve the SharePoint Health Analyzer rule "InfoPath form library forms cannot be filled out in a Web browser."

Also you can check out:

- Promoted Links App in SharePoint 2013

- Enable Sign in as Different User Option in SharePoint 2013

- Remote event receivers in SharePoint 2013

By using Central Administration:

We can resolve this by modifying in the Central Administration.

Open SharePoint 2013 Central Administration, then click General Application Settings

Then On the General Application Settings page, in the InfoPath Forms Services section, click Configure InfoPath Forms Services.

On the Configure InfoPath Forms Services page, in the User Browser-enabled Form Templates section, select the Render form templates that are browser-enabled by users check box.

Then Click on OK.

By using PowerShell:

We can do this by using PowerShell also. Open SharePoint 2013 Management Shell and then run the below command.

Set-SPInfoPathFormsService -AllowUserFormBrowserRendering $true


Saturday, April 5, 2014

SharePoint 2013 Best Practices

As you know SharePoint 2013 already in market and most of the companies started implementing SharePoint 2013. It is better to know about the best practices of SharePoint 2013.

Also you can check out:

- Differebce between Sandboxed solution and Farm Solution in SharePoint

- Change default error and successful message in infopath 2013

- SharePoint 2013 list column status wise Change row Color using jQuery

These SharePoint 2013 best practices includes towards:
Performance
Feature Overview
Capacity Planning
Installation
Upgrade & Migration
Infrastructure
Backup & Recovery
Database
Implementation and Maintenance
Apps
Developing
Debugging etc

You can check out Technet Best Practice Article.


Twitter Delicious Facebook Digg Favorites More