SharePoint4us

Explore the Experience in SharePoint 2013

Monday, April 27, 2015

How to get multiple users from SharePoint list Pragmatically in SharePoint 2013,2010?

No comments

Hi friends,

Thanks for visiting my blog .

In this post, i would like to describe about "Getting multiple users from SharePoint list Programatically".

Scenario : 
I came across a situation where i want to fetch the usernames and email IDs   from list (Column is people Picker and Check the "allow multiple users" option).

Solution : 

Please find the the below code snippet
*********************************

 SPFieldUser UsersColumn = (SPFieldUser)lstNewPrsReq.Fields.GetField("ColumnName");
 SPFieldUserValueCollection Users = (SPFieldUserValueCollection)UsersColumn.GetFieldValue(lstitemCollection[0]["ColumnName"].ToString());   
   if (Users != null)
     {                                 
  foreach (SPFieldUserValue user in Users)
               {
                        SPUser spUser = user.User;                    
                        if (spUser != null)                                               
                        strCCEmail = strCCEmail + ";" + spUser.Email;
                }                                                                           
          strCCEmail = strCCEmail.TrimStart(';');                             
     }      


strCCEmail : This string contains all the mail ids of the users for that particular list item.

hope this blog helps you........

Friday, April 24, 2015

Disabling the Throttling Limit to Specific List in SharePoint 2013, 2010

No comments


Hi friends,

Thanks for visiting my blog .

In this post, i would like to describe about "Disable throttling of List in SharePoint".

Scenario : 
I came across a situation where i want to fetch the list items  from list (consists of more than 2 lakhs).

Problem :
 when am pulling the items from the list it showing an error saying that you cannot pull items from list as it exceeds list threshold limit (by default 5000 in central administration  we can see the limit and increase but increasing here is not a good practice ).

Solution : 
we can disable  throttling limit  for particular list in which you want to query the items.
we can do this  by using powershell and object model to my knowledge.


PowerShell Script :
****************************
$web = Get-SPWeb "Site Url"
$list = $web.Lists["ListUrl"]
$list.EnableThrottling = $false
****************************

Paste in notepad and save as ".ps1 " .
1.Open the Management Powershell command prompt (run as administrator).
                 2. Execute the .ps1 file here.
                 3. Go back to the logic and try to query the list items .


Thank you hope this post helps you in understanding