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!!!