Hot answers tagged

7

How about using paging with the 'old' listdata.svc? It supports paging with the ODATA skip and top parameters like so: http://sharepointsite/_vti_bin/listdata.svc/MyList?$skip=100000&$top=10000 Then you can pull e.g. 10,000 items at a time and iterate over the list contents. This is supported in SharePoint 2010, 2013 and Online.


6

If you don't want to use the GUID, you'll have to make an extra call and get the vti_listname property from the list folder. The folder you can get by url using the getFolderByServerRelativeUrl on the SP.Web object. Example: var clientContext = SP.ClientContext.get_current(); var web = clientContext.get_web(); var folder = web....


6

Make sure that the column you include in the where clause is defined as an indexed column in SharePoint. You can check by going to the list you're querying and into List -> Settings -> Indexed Columns. It's not applicable in your CAML query, but if you have more than one 'where', ensuring the first where hits an indexed column can increase efficiency. ...


6

SPWeb.Lists.Count.ToString(); is correct way to find number of Lists for any SPWeb. You might be seeing in difference in count you see here and in Site is because SharePoint has couple of hidden list like UserInformation list, managed metadata list which are hidden from UI. Also we can hide our custom list by using powershell/server side code. To give an ...


5

Using SPList.Items property is bad practice. Each time the property is accessed, it requests all items with all fields from database. Instead you should always use SPList.GetItems(). SPList.GetItems(params string[]) - you can use it to load only the fields that you need. As far as I remember it'll only return items in the root folder of the list. SPList....


4

If you want to get the collection of "field_name + field_value", you can try: var fieldValues = currentItem.get_fieldValues(); It returns an object, the object key is field name and the object value is field value.


4

MONTH( [MyDate] ) will return 1 for January, then use the SharePoint version of the switch/case statement: =CHOOSE( MONTH([MyDate]) , 30 , 60 , 60 , 60 , 60 , 60 , 60 , 60 , 60 , 60 , 60 , 60 ) remember: if you are going to work with Dates in JavaScript then January = 0 and December = 11 All SharePoint functions: www.viewmaster365.com/functions Monthnames ...


4

If both lists are same, you can use SharePoint designer workflow to copy list item from one list to other. Below link may help you to get started: http://blogs.salmanghani.info/copy-item-workflow-using-sharepoint-designer-2010/


4

This is because of the SPWeb.Lists.Count.ToString(); return the number of all lists and libraries not only lists To can get the accurate number of lists only you should exclude the library and other list types from your code as the following int listcount=0; foreach (SPList list in Web.Lists) { if (!list.Hidden & list.BaseType != ...


4

While the other two answers here are correct in that it is fairly straightforward to hide the fields conditionally based on the Title value, what I think is going to be more of a problem for you is that you say that when all 6 fields are shown, they are all required. This presents a problem, because if you make them required fields in the list, if you hide ...


3

When you request list items via client object model, the object will return a number of parameters even if you specify none at all. Some of these include title, url, modified date, created date, check out user, etc. You can see these by storing the object as a variable and then using Dev tools to debug the page. You will see there are actually about a dozen ...


3

Your code is fine. Url is property of the item and its not affected by your parameter in GetItems. Test with a field (not property) that is not included in the parameter you pass in GetItems. item["OtherField"] Normally it should throw an exception (ArgumentException).


3

I have seen other posts where users claim that SPList.Hidden is somehow different from SharePoint Designer's option Hide from browser. It is my belief that both the code approach and the designer setting are one and the same. A hidden list does not appear on the Documents and Lists page, Quick Launch bar, the Modify Site Content page, or the Add Column ...


3

Like to note that RootFolder as you point out yourself is not a bad idea if you were to use REST (and not jsom), like this: /_api/Web/Lists?$filter=RootFolder/Name eq 'MyImages' Then just pick the first one, and you get one result with all additional list data. (Syntax tested on 365, might need $expand on-premise.)


3

I've used code like this in a console app where I was reconfiguring some lists. This enables versioning and sets limits. var depts = web.Lists.TryGetList("Depts"); if (depts != null) { depts.EnableModeration = true; depts.EnableVersioning = true; ...


3

You probably forgot to call SPList.Update method to apply the changes, for example: var tasksList = web.Lists.TryGetList("Tasks"); tasksList.EnableVersioning = true; tasksList.Update();


3

As @Evariste and @Eric mentioned in comments: CAML Query is case-insensitive. The solution was to filter the results from SPListItemCollection queryResultItems = docTypeList.GetItems(query); and check for case-sensitive. I created a small method which does this. private SPListItem FindCaseSensitive(string documentType, IEnumerable items) { ...


3

Try adding web.AllowUnsafeUpdates = true; before for loop and then after for loop add web.AllowUnsafeUpdates = false; So the code will be: try { using (SPSite site = new SPSite(siteUrl)) { using (SPWeb web = site.OpenWeb()) { web.AllowUnsafeUpdates = true; ...


3

Try following code using (SPSite site = new SPSite("Web Url")) { using (SPWeb web = site.OpenWeb()) { Console.Write(web.Lists.Count); Console.ReadLine(); } }


3

Changed var query = SP.CamlQuery() to var query = new SP.CamlQuery() problem solved. Whoops.


3

using (var oSite = new SPSite(fundURL)) { using (var oWeb = oSite.OpenWeb()) { var listWithArticles = oWeb.Lists.TryGetList("Articles"); if(listWithArticles != null) { listWithArticles.Title = "Exhibits"; listWithArticles.Update(); } } }


2

The aggregation is not something that is calculated and stored but just defined type of aggregation required or to be done. You need to calculate it your own. SharePoint displays the aggregated data by using XSLT.


2

When I add new role definition to role assignments collection I always create new instance of SPRoleDefinitionBindingsCollection and import it with SPRoleAssingment.ImportRoleDefinitionBindings method. It's not the only way I think, it's just my habit. This code has always worked for me: SPRoleAssignment roleAssignment = new SPRoleAssignment(principal); ...


2

https://code.msdn.microsoft.com/office/Ejemplos-sobre-cmo-usar-el-69cd5f16 SP GridView Sample Code with C sharp


2

There are two options in sharepoint to delete the listitem: listitem.Recycle() deletes the list item and puts it in the recycle bin listitem.Delete() deletes the item permanently If you delete a document in SharePoint using the User Interface, it’s being moved to the Recycle Bin, so that it can be restored if necessary. Calling the SPListItem.Delete() ...


2

Try this : using (SPSite site = new SPSite("http:...")) { using(SPWeb web = site.OpenWeb()) { SPList oList = web.Lists.TryGetList("listname"); if(oList != null) { foreach(Field field in oList.Fields) { if(!field....


2

To do this without building deployable code and only using the SSRS Report Builder, use the LookupSet and Join commands. Load both the Student and Course lists as datasets, setting any filter queries you might need and to join them in a tablix, you can use some expression along the lines of: =Join(LookupSet(Fields!StudentID.Value, Fields!StudentID.Value, ...


2

From what it seems, the only use of event receiver as I see here is creating the field options. There is no way SharePoint allow to display different values based on the person in a choice column. You can create a custom form (visual webpart or InfoPath) and then add all 6 options to the column and display only 3 based on the logged in user. Replace the ...


2

We can get the Checked out files using the below code. No matter what you try, you cannot get the checked out files by querying the document library as these are saved in a separate table in the database. SPDocumentLibrary library = (SPDocumentLibrary)list; IList<SPCheckedOutFile> files = library.CheckedOutFiles; foreach (SPCheckedOutFile file in ...


Only top voted, non community-wiki answers of a minimum length are eligible