SharePoint 2010, The attempted operation is prohibited because it exceeds the list view threshold

The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception

Details: System.Runtime.InteropServices.COMException: <nativehr>0×80004005</nativehr><nativestack></nativestack>The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.

I got this error while trying to change the site URL in Site Settings.

The resolution to this error is:

1. Navigate to Central Administration.

2. Go to Application Management > Manage Web Application and click on your web application to select it.

3. In the Ribbon, click on General Settings drop-down and choose “Resource Throttling”.

4. In the “List View Threshold”, increase the value (by a factor of 2, for example) and click OK.

5. Try to replicate the error.  If the error persists, increase the value again until the error goes away.

SharePoint 2010, Value does not fall within the expected range.at Microsoft.SharePoint.SPFieldMap.GetColumnNumber

If you facing this error...

if you save or read a column using splistitem["Created By"] or splistitem[internalname]...

You get this error...

Exception            Unhandled exception caught during execution of Microsoft.SharePoint.Portal.PageBase::ErrorHandler(). Exception information: Exception information: System.ArgumentException: Value does not fall within the expected range.     at Microsoft.SharePoint.SPFieldMap.GetColumnNumber(String strFieldName, Boolean bThrow)     at Microsoft.SharePoint.SPListItemCollection.GetColumnNumber(String groupName, Boolean bThrowException)     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 bThrowException)     at Microsoft.SharePoint.SPListItem.get_Item(String fieldNa...        

 

Your list has a too much columns (Lookup, Person/Group, or workflow status fields)

You need to increase your "List View Lookup Threshold"

Go to Application Management --> Manage Web Applications --> select your application --> General Setting --> Resource Throttling --> List View Lookup Threshold --> Put a number more than number of your list columns. maybe 30, 40, or 50.

and Save it.

Now It should be working!

 

Enjoy DDIBA~! Cool

SharePoint 2010, Hide My Site, My Newsfeed, My Content Link, Find People Searchbox on top navigation

To hide "My Site" on top navigation.

 

 

.ms-globalnavicon

display: none; 
}

Put that code in your master page "MySite.master"

in <Header>

</Header>

 

-----------------------------------------------------------------------------------------------------

To hide "My Newsfeed, My Content" global navigation menu.

 

 

 

.ms-globalnavmenu

display: none; 
}

Put that code in your master page "MySite.master"

in <Header>

</Header>

-----------------------------------------------------------------------------------------------------

To hide "Find People" Searchbox global navigation menu.

 

 

 

.ms-ms-globalnavsearch

display: none; 
}

Put that code in your master page "MySite.master"

in <Header>

</Header>

SharePoint 2010, SPDiagnosticsService trace log file

Use this,

 

            catch (Exception ex)

            {

                Log("your fuction,method,application name", Microsoft.SharePoint.Administration.TraceSeverity.High, Microsoft.SharePoint.Administration.EventSeverity.Error, ex.Message);

   }

 

--------------------------------------------------------------------------------------

     void Log(string source, TraceSeverity traceSeverity, EventSeverity eventSeverity, string logMessage)

        {

            SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(source, traceSeverity, eventSeverity), traceSeverity, logMessage, null);

        }

 

Now, check your log file on 14 hive, if you have any error, 

SharePoint 2010, Programmatically get multichoicevalues from list item

SharePoint 2010, Programmatically get multichoicevalues from list item

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Data;

using Microsoft.SharePoint;

 

namespace MultiChoice

{

    class Program

    {

        static void Main(string[] args)

        {

            using (SPSite site = new SPSite("http://serverName/"))

            {

                using (SPWeb web = site.OpenWeb())

                {

                    SPList list = web.Lists.TryGetList("yourListName");

                    if (list != null)

                    {

                        SPListItem item = list.Items[0];

                        SPFieldMultiChoiceValue choices = new SPFieldMultiChoiceValue(item["MultiChoice"].ToString());

                        for (int i = 0; i < choices.Count; i++)

                        {

                            Console.WriteLine(choices[i]);

                        }

                        Console.ReadLine();

                    }

                }

            }

        }

    }

}

 

Enjoy DDIBA~! Cool

 

 

SharePoint, Get User Account SPUser, SPFieldUserValue From List

Try this.

 

        public static string GetUserAccountFromList(SPListItem item)

        {

            SPFieldUserValue fieldValue = null;

            SPUser user = null;

 

            SPFieldUser UserColumn = (SPFieldUser)item.Fields.GetField("YourUserFieldName");

            fieldValue = UserColumn.GetFieldValue(item[fieldName].ToString()) as SPFieldUserValue;

 

            if (fieldValue != null)

                user = fieldValue.User;

 

            return user;

        }

Enjoy DDIBA~! Cool

SharePoint, Operation is not valid due to the current state of the object. ThrowIfMaxHttpCollectionKeysExceeded()

If you have a custom development (webpart, gridview, and etc...) on SharePoint and update/add more than 1000 items on you list... i might get some wired error like:

Operation is not valid due to the current state of the object

By default MaxHttpCollectionKeys is set to 1,000.

So, you need to increase this value in Web.Config

 

*****************************************************************

 

<appSettings>

    <add key="aspnet:MaxHttpCollectionKeys" value="10000" />

</appSettings>

*****************************************************************

 

Server Error in '/' Application.

Operation is not valid due to the current state of the object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Operation is not valid due to the current state of the object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[InvalidOperationException: Operation is not valid due to the current state of the object.]
   System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +4148319
   System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +60
   System.Web.HttpRequest.FillInFormCollection() +189

[HttpException (0x80004005): The URL-encoded form data is not valid.]
   System.Web.HttpRequest.FillInFormCollection() +11111400
   System.Web.HttpRequest.get_Form() +119
   Microsoft.SharePoint.SPGlobal.GetParametersFromHttpRequest(SPSite site, Boolean bAuthenticated) +422
   Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous) +27616569
   Microsoft.SharePoint.SPWeb.InitializeSPRequest() +223
   Microsoft.SharePoint.WebControls.SPControl.EnsureSPWebRequest(SPWeb web) +365
   Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context) +520
   Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.GetContextWeb(HttpContext context) +27
   Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PostResolveRequestCacheHandler(Object oSender, EventArgs ea) +918
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171



Version Information: Microsoft .NET Framework Version:2.0.50727.5448; ASP.NET Version:2.0.50727.5456 

 

ENJOY DDIBA~! Cool

SharePoint, How to Retrieve Get Value Text from Enhanced Rich Text Column Programmatically

How to Retrieve Text from Enhanced Rich Text Column Programmatically.

Use this code...

 

SPFieldMultiLineText spFieldMultiLineText = spListItem.Fields["EnhancedRichTextColumn"] as SPFieldMultiLineText; 

string text = spFieldMultiLineText.GetFieldValueAsText(spListItem["EnhancedRichTextColumn"]);

 

Enjoy DDIBA~! Cool

SharePoint, Set Logs in 14 hive logs folder by programmatically

Try this code...

 

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Microsoft.SharePoint.Administration;

 

namespace YourProject

{

    public class LoggingService : SPDiagnosticsServiceBase

    {

        public static string DiagnosticAreaName = "Your Diag Area Name";

 

        protected override IEnumerable<SPDiagnosticsArea> ProvideAreas()

        {

            List<SPDiagnosticsArea> areas = new List<SPDiagnosticsArea>

            { 

            new SPDiagnosticsArea(DiagnosticAreaName, new List<SPDiagnosticsCategory> { new SPDiagnosticsCategory(DiagnosticAreaName, TraceSeverity.Unexpected, EventSeverity.Error) })

            };

            return areas;

        }

 

        public static void Log(string source, TraceSeverity traceSeverity, EventSeverity eventSeverity, string logMessage)

        {

            SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(source, traceSeverity, eventSeverity), traceSeverity, logMessage, null);

        }

    }

}

And use this in your code like this...
        private void YourMethodOrFunction()
        {
            try
            {
Do... Run...
            }
            catch (Exception ex)
            {
                LoggingService.Log("Your Application Name", Microsoft.SharePoint.Administration.TraceSeverity.High, Microsoft.SharePoint.Administration.EventSeverity.Error, ex.Message);
            }
        }
And check your Log file in Logs folder.
Location: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS

Enjoy~! DDIBA~! Cool

 

SharePoint 2010, Clear Remove Delete People Editor Value Text

Clear, Remove, Delete SharePoint 2010 people editor Value Post Back Event PeopleEditor picker = PeopleSelector; picker.Accounts.Clear(); picker.Entities.Clear(); picker.ResolvedEntities.Clear(); --------------------------------------------------------------------------------------------- This code will trigger every time the page refreshes; this means, if you need to trigger it on button click, ensure you call a clearPicker function from below on OnClientClick event of your button or means similar to this.

<script type="text/javascript">

    // this registers clearPicker to run every time the page reloads

    _spBodyOnLoadFunctionNames.push("clearPicker");

 

    // this is the function that clears the picker and helper variables

    function clearPicker() {

 

        var control;

        var arr = document.getElementsByTagName("div");

        for (var i = 0; i < arr.length; i++) {

            if (arr[i].id.indexOf("upLevelDiv") > 0)

            { control = arr[i]; }

        }

        control.innerHTML = '';

 

        arr = document.getElementsByTagName("input");

        for (var i = 0; i < arr.length; i++) {

            if (arr[i].name.indexOf("hiddenSpanData") > 0)

            { control = arr[i]; }

        }

        control.value = '';

    }

</script>

 

That’s it; the upLevelDiv and hiddenSpanData now contains no resolved values and the people editor appears cleared.


Donate Me!

Please Help Us to Maintain This Site!

About the Author