Tuesday, May 5, 2015

System.ArgumentException: Value does not fall within the expected range

This error was faced in one of the SharePoint Calendar list view web part. Normally, single day event is display properly but recurring event is not getting display in Disp.aspx page. It gives an error like 'Value does not fall within the expected range' in web part maintenance page.

After looking into SharePoint log file, I found below error details...

"System.ArgumentException: Value does not fall within the expected range. at Microsoft.SharePoint.SPFieldMap.GetColumnNumber(String strFieldName, Boolean bThrow) at Microsoft.SharePoint.SPListItemCollection.GetRawValue(String fieldname, Int32 iIndex, Boolean bThrow) at Microsoft.SharePoint.SPListItem.GetValue(SPField fld, Int32 columnNumber, Boolean bRaw, Boolean bThrowException) at Microsoft.SharePoint.SPListItem.GetValue(String strName, Boolean bThrowIfValueMissing, Boolean bThrowIfFieldMissing) at Microsoft.SharePoint.SPListItem.get_Item(String fieldName) at Microsoft.SharePoint.SPListItem.GetFieldValue(String fieldName) at Microsoft.SharePoint.WebControls.FormAuthorEditorFormattedString.Render(HtmlTextWriter output) at System.Web.UI.Control.RenderControlIn... f79f039d-c61f-309c-09b3-d284a913f679"

System.ArgumentException: Value does not fall within the expected range error is occurred due to throttling limit set at List view lookup in web application general settings.

To overcome this issue,

  1. Navigate to SharePoint 2013 Central Administration
  2. In Application Management section, click on Web Applications >> Manage Web Applications
  3. Select the SharePoint site in which you face the issue
  4. Click on General Settings >> Resource Throttling
  5. Navigate to List View Threshold section, specify the maximum value like 15 or 20 based on lookup, person/group or workflow status field used in the list. Default value for List View Threshold is 8. 



Enjoy SharePoint!!!

Friday, May 1, 2015

Cloud Business App: Save Operation Failed. The etag value in the request header does not match with the current etag value of the object

In Cloud Business App, this issue occurred when trying to update the record using SharePoint 2013 custom list data source from View Announcement HTML client screen. When I click on Save button in Edit form. The cloud business app is developed using Visual Studio 2013.

To overcome this issue add following java script in HTML Client Project >> Default.htm page inside the <Body> tag.

<script type="text/javascript">
var origMetadataReadFunc = OData.metadataHandler.read;
OData.metadataHandler.read = function (response, context) {
origMetadataReadFunc.call(OData.metadataHandler, response, context);
var data = response.data,
schema = data && data.dataServices && data.dataServices.schema && data.dataServices.schema[0],
entities = schema && schema.entityType || [];
entities.forEach(function (entity) {
var i,
property,
properties = entity.property || [];
for (i = properties.length - 1; i >= 0; i--) {
property = properties[i];
if (property.name === "Microsoft_LightSwitch_ETag") {
property.type = "Edm.String";
break;
}
}
});
};
var origJsonReadFunc = OData.jsonHandler.read;
OData.jsonHandler.read = function (response, context) {
var result = origJsonReadFunc.call(OData.jsonHandler, response, context);
var data = response.data, results = data.results;
if (results) {
results.forEach(function (entity) {
if (entity.__metadata.etag) {
var etag = entity.__metadata.etag,
firstIndex = etag.indexOf("'"),
lastIndex = etag.lastIndexOf("'"),
coreEtag = "";
for (var i = firstIndex + 1; i < lastIndex; i++) {
var char = etag[i];
coreEtag += char;
if (char == "'") {
coreEtag += "'";
if (etag[i + 1] == "'") {
i++;
}
}
}
entity.__metadata.etag = etag.substr(0, firstIndex + 1) + coreEtag + etag.substr(lastIndex);
}
});
}
return result;
};
</script>
Enjoy SharePoint!!!

Wednesday, April 15, 2015

How to kill installed windows service which is stuck at starting state

One day I have installed the windows service using developer command line tool. Service is installed successfully. After that I tried to start the service from command prompt, suddenly it got stuck at starting.

At that time, I thought to kill the process using command line because I cannot reboot the server.

Step 1: First of all you need to find the service name which has stuck at starting state

Navigate to Run >> type Services.msc

It will open the Services window, find the installed windows service which has stuck at starting state and click on it and note down the name of service.

Step 2: Now open the command prompt and type the below command

> sc queryex ServiceName

It will result as below and note down the PID.



Step 3: From command prompt type the below command to kill the service using PID

>taskkill /f /pid 11140


Enjoy SharePoint!!!

How to get image URL using JSOM in SharePoint 2013

Use below code to get the image URL from the Image field which has type as Hyperlink or Picture in SharePoint custom list.

var user;
var clientContext;
var lstItem;
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', loadImage);

function loadImage() {
DisplayImage() ;
}
function DisplayImage () {

     clientContext = new SP.ClientContext();
     var groupCollection = clientContext.get_web().get_siteGroups();
     user = clientContext.get_web().get_currentUser();
     clientContext.load(user);
     clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded() {
var lst = clientContext.get_web().get_lists().getByTitle(“ListName”);
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View> <Query> <Where><Eq><FieldRef Name=\ID\' /><Value Type=\'Text\'>1</Value></Eq></Where> </Query> <ViewFields><FieldRef Name=\'Image\' /><FieldRef Name=\'ID\' /></ViewFields> </View>');
    lstItem= lst.getItems(camlQuery);
    clientContext.load(lstItem);
    clientContext.executeQueryAsync(onSuccess, onQueryFailed);
}
function onSuccess()
{
            var ListEnum = lstItem.getEnumerator();
           
            while(ListEnum.moveNext()){
                        var objListItem=ListEnum.get_current();
                        document.getElementById("ImageID").src= objListItem.get_item("Image").get_url();
                        }
}
function onQueryFailed(sender, args) {
    console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}


Enjoy SharePoint!!!

Friday, February 13, 2015

Error occurred in deployment step 'Install app for SharePoint': The provided App differs from another App with the same version and product ID

In SharePoint Provider hosted app, I got below error while deploying the app in development environment.

"Error occurred in deployment step 'Install app for SharePoint': The provided App differs from another App with the same version and product ID"

To overcome this issue, you need to change the major or minor version in AppManifest.xml file of Provider hosted app and it should work.

Enjoy SharePoint!!!

Wednesday, February 4, 2015

This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.

When I was tried to access SharePoint 2013 application, I got below error. It gave me the same error while accessing the Central Administration too.

This error occurs due to SQL Server service is not started.

To start the service Go to Start >> Run >> Services.msc >> SQL Server (MSSQLServer)
Click on Start

Navigate to the browser and refresh the page, SharePoint 2013 web application is working fine.

Enjoy SharePoint!!!

Tuesday, February 3, 2015

Route document using Content Organizer in SharePoint based on metadata

SharePoint provides out of box feature to automatically route document specific libraries or folder is called Content Organizer. It can be used to manage document library constantly. Content organizer is automatically move document to specific target location based on specified metadata.

Using this feature end user do not to remember where to upload the document. It will automatically route the document based on defined custom settings & rules or applying proper manage metadata. This is a very powerful feature of SharePoint to organize the documents consistently.

With Content Organizer, you can automatically route document from one site collection to another site collection. Make sure you should have Content Organizer feature is activated in another site collection. 

You can route content or document within the farm using content organizer.

Content organizer will work only with content types that are inherited from document content type.

How to use content organizer in site
1. Activate Content Organizer feature
2. Create library or folder to route document
3. Configure content organizer settings
4. Create content organizer rule
5. Upload document in Drop off Library
6. Verify the routed document in specified library or folder

Step 1: Activate Content Organizer feature
  • Navigate to SharePoint 2013 Web Application
  • Navigate to Site Settings >> Site Actions >> Manage Site Features
  • Click on Activate button to enable Content Organizer feature from the list of features

  • Once Content Organizer activated it will add Content Organizer settings and Content Organizer Rules options inside Site Settings >> Site Administration
  • Also creates new document library called Drop off Library. You can see it in quick launch bar of home page.



Step 2: Create library or folder to route document
  • Click on Site Contents from quick launch or from clicking on gear icon from top right corner of the screen
  • Click on Add an app
  • Click on Document library app
  • Give name to document library as "SampleDocLib"
  • Click on Create

Step 3: Configure content organizer settings
  • Navigate to Site Settings >> Site Administration >> Content Organizer Settings
  • Select the check box for Redirect Users to the Drop Off library to route user to upload the document in this library and route it based on defined rules.
  • If you would like to route content or document to another site’s library or folder then select the Allow rule to specify another site as a target location under Send to Another Site section.




Step 4: Create content organizer rule
  • Navigate to Site Settings >> Site Administration >> Content Organizer Rules
  • Click on New Item to add new rule
  • Provide rule name as Sample Rule
  • Select Content type group as Document Content Type and type as Document in Submission’s Content type section. You can also add custom content type that must be inherited from document content type.
  • In Conditions section, select property as Title and operator as contains all of and value as Sample in property-based conditions.
  • Select newly created document library named “SampleDocLib” in target location section by clicking on browse button.
  • Click OK.



  • Once you add new rule it will create new item in content organizer rule. You can create many rules and define the priority of rules as well.


Step 5: Upload document in Drop off Library
  • Click on Drop Off Library from quick launch in left side navigation
  • Click on New Document
  • Select the document and give title values as “Sample HTML Design file”
  • Click Submit


  • If content organizer rule named Sample Rule is match with the metadata "Sample" which we added for uploaded document then it routes the document to "SampleDocLib" library


  • And if Sample rule is not match then it will upload the document in Drop off library itself.



  • Later on site administrator will take decision to move the document from Drop off library
Step 6: Verify the routed document in specified library or folder
  • Navigate to document library named "SampleDocLib"
  • You will see the routed document in the library as we have mentioned the meta data as "Sample".


Enjoy SharePoint!!!

Thursday, January 15, 2015

Indexed column in SharePoint List

Indexed column in SharePoint list is used to improve performance of query to work with large list efficiently.

You can create index on single column (Specify primary column for index) or specify compound index on two columns (Specify primary & secondary column for index).

SharePoint list instance support a maximum of 20 indices.

Not all the field types can participate in composite index.

When you create an indexed column, it requires extra storage space to maintain it and also adds unnecessary overhead. So you should create index only to columns that will be used in filtering view on list.

Managed metadata navigation and filtering require indexing column on list.       





Indexed column also affect the throttling for list that contains large amount of items.

Suppose you build query that returns first 100 items from non-indexed Title column with sort, then query would have to scan all the items from list in content database to define the sort order for first 100 items. Due to that query become throttled. To avoid such issue, create index on Title column to returns the first 100 sorted items instead of scanning all the list items from content database.

Not all column types can be indexed. Following table shows supported and unsupported column types for indexing in list.


Supported column types
Unsupported column types
Single line of text
Multiple lines of text
Choice field having single value
Hyperlink or Picture
Number
Calculated field
Date/Time
Yes/No
Lookup (Single value)
Custom field type
Person or group (single value)
External data
Currency

Title (only in list)

Managed metadata


How to create index column in list:

1. Navigate to SharePoint List >> List Settings
2. Click on Indexed Columns

3. Click on Create Index link
4. Select Primary column as Title from the drop down list and keep secondary column as blank if we do not require any compound index column.

5. Click on Create button to generate new index column and will display as below. You can also edit the indexed column by clicking on it.
 
Enjoy SharePoint!!!

Thursday, January 8, 2015

Difference between Web Part and Visual Web Part

Web Part
Visual Web Part
In Web part, everything has to done through code for UI as well as logic. It does not provide visual UI effect. Hence it affects the productivity.

Visual web part is a web part which contains the reference of user control in which we can place controls from designer and have separate code file to add business logic inside it. It improves the productivity to design the complex UI.
Web part can be deployed as a sandbox solution hence it will not impact the whole farm if any issue with simple web part code.

In SharePoint 2010,Visual web part cannot be deployed as a sandbox solution. It can be deployed as a farm solution.

You can use Visual studio 2010 SharePoint power tools extension to deploy visual web part as a sandbox solution. Power tool generate the complied code with user control as a part of assembly

Few SharePoint or Asp.Net web controls are not supported in sandbox solution due to that visual web part gives an error occasionally.
Web part can be extended by inheriting from the WebPart class. We cab reuse the web part functionality.
Visual web parts cannot be extended.
Web part does not affect the performance compare to visual web part.
It has user control and web part inside it, thus it takes long time to load the user control due to that it affects the performance.
Declaring web part properties and connection is easily doable in simple web part as code is written in web part itself.
It is awkward to manage the web part properties and connection declaration in visual web part as it has includes multiple files.

Note: In SharePoint 2013, there is only one template to create web part named SharePoint 2013 Visual Web Path which include the user control in solution as complied assembly that can be deployed as sandbox solution.

Enjoy SharePoint!!!

Wednesday, January 7, 2015

SharePoint 2013 Apps

SharePoint 2013 Apps are self-contained pieces of functionality that can be used to extend the SharePoint web site functionality.

SharePoint 2013 App runs outside of SharePoint environment.

SharePoint App can be easily provision on site and to be removed cleanly as no longer need.

Apps can available for user through app catalog or SharePoint Store.

Microsoft has introduced the new app model in SharePoint 2013 to overcome the limitations of SharePoint sandbox solution. Sandbox solutions are depreciated in SharePoint 2013.

1. Apps must be supported in Office 365 and in on-premises farms.
2. App code never runs within the SharePoint host environment.
3. App code programs against SharePoint sites by using web service entry points to minimize version-specific dependencies.
4. App code is authenticated and runs under a distinct identity.
5. App permissions can be configured independently of user permissions.
6. Apps are deployed by using a publishing scheme based on app catalogs.
7. Apps that are published in a catalog are easier to discover, install, and upgrade.

Types of SharePoint 2013 Apps:

SharePoint Hosted App: SharePoint hosted apps are installed on on-premise SharePoint 2013 environment and it’s called host web. So, all the resources are hosted on on-premise or Office 365 environment. Apps get authorized by using internal authentication means single sign in user. No serve code allowed, only client side java script code is used.

Cloud Hosted App (Auto Hosted App & Provider Hosted App):

Provider hosted apps are installed on host web, but remote components are hosted on another server. Apps are deployed and hosted outside the SharePoint farm environment. Apps get authorize by OAuth or JavaScript Cross domain library.

Auto hosted apps, remote components are provisioned and deployed on Microsoft Azure. Apps get authorize by OAuth or JavaScript Cross domain library. Like Provider hosted app, auto hosted app interact with SharePoint site and uses resources that are located at remote site.

Note: Microsoft announced an end of auto hosted app preview. Click here on link below for more details.

http://blogs.office.com/2014/05/16/update-on-autohosted-apps-preview-program/

Why Apps for SharePoint introduced? Or Limitation and constraints of SharePoint Solution

1. Custom code runs within the SharePoint host environment that results in creating problem of stability of farm.
2. Up gradation of on-premise SharePoint farm to new version of SharePoint. In this case there is a lot of rework for custom code development of SharePoint Solution.
3. Security and Permissions concerns with SharePoint Solution development. Running of custom code inside sandbox solution is not protects the content of farm. It protects against the farm and site collections of it.
4. Impersonation issue with Sandbox solution. Sandbox solution runs under the context of current user privileged in SharePoint.
5. To install solution on farm requires the farm administrator permission and IIS reset on all the WFE servers which affect end users work.

Required Service Applications for SharePoint 2013 Apps:

SharePoint 2013 uses two service applications to manage the environment for App for SharePoint.
App Management Service: It is new service introduced in SharePoint 2013.
The App Management Service has its own database that is used to store the configuration details for apps as they are installed and configured. It is also responsible for tracking other types of app-specific configuration data that deals with app security principals, app permissions, and app licensing.

• App Instance metadata
• App security principals
• App Permissions
• App Licensing

Creating an instance of the App Management Service is easier because it can be done manually via Central Administration or by using the Farm Creation Wizard.

Site Subscription Setting Service: It was introduced in SharePoint 2010.
Site Subscription Settings Service is used to manage tenancies. Each time a new tenancy is created; this service adds configuration data for it in its own database. The Site Subscription Settings Service is particularly important to the SharePoint app model due to this requirement SharePoint apps must always be installed and run within the context of a specific tenancy.

• Tenancy management
• Site Collection mapping

Creating an instance of the Site Subscription Settings Service is a bit trickier because it must be done by using Windows Power shell. However, when you create an instance of the Site Subscription Settings Service by using Windows Power shell, it automatically creates the default tenancy, which then makes it possible to install SharePoint apps in sites throughout the farm.

A SharePoint 2013 tenancy is a set of site collections in either a SharePoint farm or in SharePoint Online.

App Installation Scope:

Site Scope: The app is installed and launched within the scope of the same SharePoint site. In this scenario, the host web will always be the same site where the app has been installed.

Tenant Scope: In which host web cannot be the same site where the app has been installed.
In this scenario, an app is installed in a special type of SharePoint site known as an app catalog site. After the app has been installed in an app catalog site, the app can then be configured so that users can launch it from other sites.


Enjoy SharePoint!!!