API for interacting with SharePoint from .NET code deployed to the server.

learn more… | top users | synonyms

28
votes
2answers
7k views

When to use OpenWeb() vs RootWeb

I am a little confused on the pro's and con's of each. When is it good to use OpenWeb() vs RootWeb, especially in the context of a using statement.
19
votes
3answers
1k views

Feature based XML vs. Object Model: Which is better for content type development?

I've been researching a few different ways to create content types and I recently discovered that you can use the Object Model to do this. All of the examples I have found online typically use XML ...
11
votes
4answers
7k views

How to automate entry of external column data in BCS?

I have a document library, Resumes, that has a large number of resumes in it. There is a regular column on that library, called EmployeeID, that is already populated. I have an external content type ...
9
votes
3answers
3k views

Is there a way to see if an SPField was created by a user?

I have some code where I am going through all of the Fields that belong to a content type. I'm curious if there is a way to check to see if the SPField was created by a user or if it is a system ...
7
votes
5answers
10k views

In which situation use SPSecurity.RunWithElevatedPrivileges with superusertoken?

i have given permission only read only to Users Group.so there are not access to see listitem or any list. i have create application page with SPGridview with bind listitem. this page access by this ...
7
votes
3answers
25k views

Sharepoint 2010 how to get all items in a folder contained in a list?

I have a list that contains folders. Using c# and object model, how can I see if the folder contains any items, or return a collection of all the items in that folder.
6
votes
1answer
3k views

Checking existence before using GetItemById

I am getting an item by using GetItemById but I want to check before using it whether the item exists or not. I don't want to use a query as the main purpose of using GetItemById is performance. ...
6
votes
3answers
2k views

How can I modify a file stored in SharePoint via PowerShell?

I have some files in SP 2010 that are simply HTML, and I need to modify the contents of those files in a systematic manner. Is there a good way to do this using powershell? Imagine that I want to ...
6
votes
2answers
204 views

Choosing between API and web services

We are designing a system where we will have a service facade, behind this facade will be functionality to update SharePoint. For example to move an item from one list to another. What we are ...
6
votes
1answer
3k views

Fastest way for looping through a SPWebCollection

I've developed a console application for looping through all the webs inside my SharePoint 2010 site, but it's kind of slow, until the point that it throws OutOfMemory exception. This is the code I ...
6
votes
2answers
276 views

SharePoint App VS Object Model

For designing solutions I am confused with whole Apps concept in 2013. What is Microsoft's guidance for when to use a SharePoint app and when to go for a traditional client or server object model ...
5
votes
3answers
2k views

Should I dispose SPWeb or SPList?

I am doing a whole bunch of things with one SPWeb and many SPLists. If I just dispose web in the finally section would that dispose all of SPLists that I instantiated? (btw, I understand the concept ...
5
votes
6answers
893 views

SharePoint 2007 : How to sign out user?

I've an application build on SharePoint 2007 platform, the problem is in Mozilla FireFox, the sign out button does not successfully sign out the current login user, I believe SharePoint 2007 is not ...
5
votes
1answer
280 views

How to programatically determine if 2013 running in '14 compatibility mode' (SP 2010)

How can you programmatically determine if a site collection is running in '14 compatibility mode' (so it looks like SharePoint 2010)?
5
votes
1answer
457 views

Custom Web Service not cannot find User

I have created a Custom Web Service for my .NET application that performs various functions against a Sharepoint 2010 site. I use a standard function to run each function as an impersonated user (so ...
4
votes
2answers
418 views

Performance of search vs. using the object model?

Does anyone know how the performance of searching for items compares to using the object model to access them? When I say "object model" i mean using SPList to get a collection of SPListItems and ...
4
votes
2answers
1k views

Is it possible to have a single document referenced by two different document libraries?

Business Requirements: My customer wants to be able to associate one document with multiple projects. E.g., a set of specifications for a piece of equipment that will be used in multiple projects. ...
4
votes
2answers
3k views

Iterate through discussion list

I have SharePoint 2007 discussion list. I want to iterate over all items in the list, so I do the following: var list = web.Lists["discussion"]; var listItems = list.Items; foreach (var listItem in ...
4
votes
2answers
335 views

Efficiently determine if a List is using item level security

How can you efficiently determine if any of the items in a List don't inherit their security from the List? You could use SPListItem.HasUniqueRoleAssignments but this would require iterating through ...
4
votes
1answer
7k views

How to update a deployed content-type?

I created a content-type and applied it inside a document library. Now, if I go to the conent-type gallery and delete one of the fields, and then go back to the library and view the available ...
4
votes
1answer
5k views

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

this code thow an exception at "Item.Update();" private void AddEmail() { site = SPContext.Current.Site; web = site.RootWeb; ...
4
votes
1answer
2k views

How do I remove all users from an SPGroup object?

I have an SPGroup object populated, how can I remove all members from the group, so that essentially I start with a fresh group. I can't delete and recreate it, so I need a way to work with the ...
4
votes
3answers
729 views

How to programmatically modify item level permissions prior to first save?

I've got a situation where there are strict permissions requirements on an a list of which I already have written a custom form. The requirement is that upon creation, based on metadata, only certain ...
4
votes
1answer
455 views

how to programetically get the type (TemplateType) of a Library using the item url

Imagine if you have image url which is existing within a site collection in Sitecollectionimages library: testserver/Sitecollectionimages/image.jpg How can I get the TemplateType (which kind of ...
4
votes
3answers
820 views

What options are available to me to find lists that were created using a specific list definition?

I have many lists, some of which were created using a custom and now-obsolete list definition. I need a programmatic way of finding out which lists were created using that old definition. Currently ...
4
votes
1answer
2k views

How to find the Author Name using SP Client Context in SharePoint 2010?

I am trying to find the Author Name(created by) for a given Item Id using the SP Client context in SharePoint 2010. Below the code snippet var ctx = new SP.ClientContext.get_current(); ...
3
votes
1answer
470 views

Possible to get all SiteCollections in a WebApplication from SPContext.Current?

I would like to look at all Site Collections that are in the current web application based on SPContext.Current. Is there a way to do this? If not, how can I achieve this?
3
votes
2answers
1k views

SPList.GetItems(SPList.DefaultView) returns only visible items

WSPList.GetItems(SPList.DefaultView) only returns the number of items set to return in throttling settings on the view. I'm aware that I can increase the item limit for the view, but the users are ...
3
votes
1answer
5k views

How do I query a list using CAML and SPQuery?

I have a SPList but I don't need to go through everything in that list. I need to establish a CAML query so I can limit the list items. Then, go thru each item from the query result and do something. ...
3
votes
4answers
9k views

Make a copy of sharepoint site under a new name

Since we can't save SharePoint site (with publishing feature enabled) as Template, I'm looking for a way to do this programmatically : Make a copy of "SiteA" with a new name "SiteB" under the ...
3
votes
2answers
91 views

Getting spuser from multiple types of information

If this sounds confusing it's because I'm al little confused on it myself. Basically I have an application (originally written by someone else but never finished) that needs to perform various actions ...
3
votes
1answer
867 views

Using GetDataTable() hoses my SPFieldLookValueCollection!

I am trying to use GetDataTable on an SPListItemCollection. I have run into a situation where my SPFieldLookupValueCollections in this list are being converted to a string when they are stored in the ...
3
votes
3answers
6k views

Sharepoint 2010: Custom “New Item” form - showing ribbon and binding events to ribbon buttons

We've created a custom New Item page for our list on our site in Sharepoint 2010 with this code: <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <table ...
3
votes
1answer
696 views

SPLongOperation never ends

I have an SPLongOperation that occasionally fails to redirect the user to a new page when the operation completes. I'm not sure what circumstances cause the problem, since I don't yet have a reliable ...
3
votes
1answer
225 views

Needed help to build caml Query with multiple <And>

I am getting a query from list view by view.Query i got the following <QUERY> <GroupBy Collapse="TRUE" GroupLimit="100"><FieldRef Name="AlertGrp" /></GroupBy> ...
3
votes
1answer
90 views

How do i “Refresh” each site collection's permissions?

My network admin have deactivated a lot of users from the Active Directory, and recreated them using the same username but with a different OU, Now the SP 2010 does not recognize these users or their ...
3
votes
3answers
1k views

How to create InfoPath forms dynamically?

I have an InfoPath form published to a library... I need to create forms dynamically with siteuser as form name... I need to achieve it in Object Model... Can any of you help me on this...?
3
votes
3answers
957 views

Problem with SPList.SaveAsTemplate

I have never really had too much cause to use this method before but I am developing some generic classes to deal with column, content type and list management for use in a series of features. My ...
3
votes
1answer
958 views

Creating Managed Metadata Field from XML definition

I have successfully recreated all other Column types in SharePoint using the SPFieldCollection.AddFieldAsXml(string xml) method. However, the same method fails for the TaxonomyFieldTypeMulti field ...
3
votes
2answers
1k views

How can I implement SharePoint JSGrid filtering and grouping functionality?

I am working on SharePoint JSGrid. I am able to implement the sort functionality in JSGrid. Now I want to implement the grouping and filtering in my custom JSGrid. For filtering we have to attached ...
2
votes
2answers
1k views

Programmatically retrieve the MySite URL of user

Let's say that we have the SPUser object of current user - how do I programmatically retrieve his mysite URL path, for example "mydomain:8080/personal/saltarski"? Currently I do it through string ...
2
votes
1answer
309 views

Why do I sometimes have to use different SPQuery tags?

Every SPQuery's query should have <View><Query> query... </Query></View> tags? Sometimes I have to put without those tags to get it work and some times I have to put it ...
2
votes
3answers
4k views

Get absolute URL to listitem's default display form

I need to have an absolute URL of a listitem's display form - currently I do it the following way: On http://mydomain.com/: item.ParentList.ParentWeb.Url.TrimEnd('/') //"http://mydomain.com" + "/" ...
2
votes
3answers
99 views

To Dispose or Not to Dispose - IDisposable Passed as Function Parameter

If an IDisposable SharePoint object is passed into a function, does an explicit Dispose() call need to be made on it? Example: public void TheCallingFunction() { SPSite site = ...
2
votes
1answer
634 views

Programmatically get the central administration site SPWeb using server object model

Like in the title - is there a method of getting it without supplying the URL?
2
votes
1answer
337 views

Is there a way to only clear a specific item from the recycle bin?

I know I can empty the recycle bin for a site collection with the following: public static bool EmptyRecycleBin(string siteCollection) { try { using ...
2
votes
3answers
1k views

Programatically searching the current site collection only

I'm trying to programatically search a sharepoint site. The problem is, the results returned are from all site collections. How can I limit my search to only one site collection. Here is how my code ...
2
votes
2answers
4k views

Performance of Client Object Model vs. Server Object Model

We are looking to deploy an Intranet using SharePoint Foundation. I am targeting the Client Object Model for this project to avoid Master Page customization and building custom Webparts and leverage ...
2
votes
2answers
648 views

How do I query several lists with the Object Model and merge the results?

Is it possible to with the Object Model query several lists at the same time and get the result merged together? Something like linked sources in SharePoint Designer? I have created a web part that ...
2
votes
1answer
369 views

SPDocumentLibrary.CheckedOutFiles does not return all files

I am working through some code samples on MSDN that is suppose to return Checked Out files but my tests is showing a problem. Here you can see that both "default" and "foo" in my Page library are ...