Hot answers tagged list
8
This is related how instance of SPListItem is being created. Actually in both cases new item is added to the collection of items in list, in first case new item is added explicitly, in the second one implicitly.
The point is, that for initializing collection of items in list is used the same method GetItems but with different queries.
...
8
You can find list template ID in Visual studio by looking at Schema.xml but you won't going to find list ID.
To get list ID you can use this code in VS,
localhost.Lists ls = new WebApplication3.localhost.Lists();
ls.Credentials = new System.Net.NetworkCredential("sunil", "password");
ls.Url = "http://mossserver/_vti_bin/Lists.asmx";
var lsturl = ...
7
Any kind of hardcoded path is, in general, opposite from best practice so opening a SPWeb or SPList object directly from its full server URL is a no-no.
To get the SPWeb object, if you are sure your code will always run in your desired web it is perfectly okay to use SPContext.Current.Web. In all other cases, you might want to look at something like the ...
6
You can specify Location="CommandUI.Ribbon.ListView" and RegistrationType="ContentType" with ID set to 0x01 for custom button to appear on ListView pages of all the lists.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="ShowHelloWorldButton"
...
6
The approach of deleting the list and recreating the list is the fastest & most efficient (since you are deleting all the list items) -
Get-SPWeb $FooUrl | % { $_.Lists.Delete([System.Guid]$_.Lists["FooList"].ID) }
The above deletes the list and you can then recreate the list with its template, etc.
6
If is only about viewing, then you should probably consider Views or
go for Target Audience (this is will hide items from view
automatically without changing permissions - does require User
Profile)
If you really need permissions than try building a workflow on
particularly those conditions so that everytime a new list item gets
added permissions are set
5
Why don't you step through it using the JS debugging tools available in most major browsers (IE, FF, Chrome). That combined with fiddler are the main tools I need to figure out weird things like this.
Off the top of my head, I would move the fadein, animate, and hover code into the onsuccess function at the end.
5
If you want an event receiver on anything, then it's best to attach it to the content type Item (0x01)
Example: CharlieDigital: Programmatically Adding an Event Receiver to a Content Type
5
Use method SPFolder.MoveTo for this purpose.
Example code:
SPList list = web.Lists["Important Items"];
list.RootFolder.MoveTo("II");
P.S. Tested, works as expected.
5
The SPList class does not have an AllItems property. Neither does it have a GetItem method. So, there is no difference between these two, they are both invalid.
So, the following code:
SPList list = SPContext.Current.List;
list.AllItems;
list.GetItem();
Would generate the following errors:
'Microsoft.SharePoint.SPList' does ...
5
It’s better to use the Delete() method of SPWeb.Lists instead of using the Delete() method on the SPList because the latter doesn't delete lists properly sometimes. Try something like:
SPWeb mySite= SPContext.Current.Web;
SPList myCustomList = mySite.Lists["MyCustomList"];
mySite.Lists.Delete(myCustomList.ID);
mySite.Update();
5
Might want to take a look at this article
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.speventreceiverbase.disableeventfiring(v=office.12).aspx
Basically, what your looking for is something like this
base.DisableEventFiring();
item.update();
base.EnableEventFiring();
5
I think you could do this in a workflow made in SharePoint Designer.
You would need a second list to store the budget total, and remaining budget (starts off as both the same figure). These would be in two columns (Total Budget, Remaining Budget), and you'd just have a single item with the relevant data in each column.
The workflow would fire when an Item ...
5
There is absolutely no performanve improvement by using the lists.asmx web service over using CAML directly.
lists.asmx is just receiving your CAML passing it on to the SharePoint object model, format the result as XML.
Sending request/response over the network (even internal on the server) and formatting SOAP messages isn't going to speed up things when ...
5
Interesting Question.
I think a better approach is to Create Custom List Column Type that can work as per your business logic. If you still need to use rich text column, please continue reading... :-)
Traditional Webparts are actually server side controls which are processed by SharePoint(actually ASP.NET) runtime and the corresponding HTML markup is ...
5
You should try
$libraries = $web.lists | Where-Object { $_.BaseType -Eq "DocumentLibrary" }
$libraries | Format-Table title,id -AutoSize
$lists = $web.lists | Where-Object { $_.BaseType -Eq "GenericList" }
$lists | Format-Table title,id -AutoSize
The key here, is the SPList.BaseType property.
As decribed in the SPBaseType Enumeration, there are other ...
5
You should use the Internal Name of the column, so its probably:
Link_x0020_to_x0020_Page
Easy way to check the internal name is from the url when you edit the column, and check the "Field=" part of the URL:
FldEdit.aspx?List=%7B6045095F%2DC5AF%2D47D5%2DA481%2D27665B46E343%7D&Field=Link%5Fx0020%5Fto%5Fx0020%5FPage
Replace %5F with underscore, or ...
4
Concerning the answer with reference to
S.Y.M. Wong-A-Ton How to submit the rows of a repeating table in InfoPath to a SharePoint list
I managed to succeed in running the code from that article in Infopath 2010 (Sharepoint Online/Office 365) only after I changed CAML template XML file content from given in article:
<?xml version="1.0" ...
4
All the ribbon definitions are stored in this file:
C:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\14\TEMPLATE\GLOBAL\XML\CMDUI.XML
Action JS code for most of these ribbon elements you can find here:
C:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\14\TEMPLATE\LAYOUTS\SP.Ribbon.debug.js
Actions for ...
4
There are several way that you could do this. You could use an event receiver to enforce the constraint or you could use a field set to the value of the individual's user name and set it to be unique. You could do this with a workflow if you wanted a "code free" way of doing it. However, they could go back and change the value of this field.
In this case, I ...
4
It depends on the "context". In a web part or application page, use SPContext. A lot of example code you see on the web uses a console app for simplicity - these would use the SPSite constructor with a string parameter representing the url. In a Feature receiver you'd use (SPWeb)properties.Feature.Parent.
Bottom line is, if the code is being executed ...
4
I'd highly discourage doing this kind of operation.
Even though reads from the content database only makes your installation unsupported as long as they are occuring, you shouldn't do them.
The problems you'll run into are:
You are very likely to affect SharePoints operations in unsupported ways remember you can't even read without introducing locks
You ...
4
Depending on the list you can save emails to them. If you mean emailing to a list then that is possible with announcements and discussion boards. Here's how to set that up:
Go to the List that you want to save emails to.
Go to the List tab under List Tools -> click List Settings
Click the Incoming e-mail settings
Select Yes under "Allow this list to ...
4
You have to use SPFieldUrlValue. Here is an example:
string FullURL = artistWeb.Site.MakeFullUrl(relURL);
SPFieldUrlValue UrlValue = new SPFieldUrlValue();
UrlValue.Description = "Put desciption here";
UrlValue.Url = FullUrl;
listItem["URL"] = UrlValue;
listItem.Update();
4
Why don't you use a SPAlertHandler to change how alerts work for this list? Then you can decide when an alert is sent or not in C# code.
http://msdn.microsoft.com/en-us/library/bb897791(v=office.14).aspx
public override bool OnNotification(SPAlertHandlerParams ahp)
{
try
{
using (SPSite site = new SPSite(ahp.siteUrl + ahp.webUrl))
...
4
It is because SharePoint Multilingual User Interface (MUI) translates also column titles. What you did was that you overrode the default English MUI translation of the Title field to "title123". However, when you switch over to German MUI, it will use the German default translation of the Title field. You would need to change it also on the German MUI side.
...
4
ListItem["Property Name"] - Gets or sets a field value in the item based on the field’s title, internal name, or static name.
ListItem.Properties["Property Name"] - Gets metadata for the item.
In my practice the best usage is use ListItem[fieldId] for SharePoint OOTB fields, because you have SPBuiltInFieldIds enumeration.
4
When you want to retrieve string values, use this type of strategy.
private string GetFieldValue(SPListItem li,string FieldName)
{
var field = li.Fields.GetField(FieldName);
object value = li[FieldName];
return field.GetFieldValueAsText(value);
}
By doing a ListItem["FieldName"].Tostring(), you're running the risk of getting data back in a way ...
4
This is a well known and very difficult to solve problem, especially when it comes to large volumes of data. Even not touching SharePoint, you might have noticed that many systems (Google is an obvious example) return only approximate number of filtered elements.
Basically the only thing you can do is to perform the same query but exclude permissions and ...
3
You can do that with a custom action. Use "Microsoft.SharePoint.ListEdit" as custom location and "GeneralSettings" as groupid. There you can set the path to you custom settingspage.
Samplecode:
Id="Custom.Configuration.ListCustomSettings"
GroupId="GeneralSettings"
Location="Microsoft.SharePoint.ListEdit"
RequireSiteAdministrator="FALSE"
Sequence="100"
...
Only top voted, non community-wiki answers of a minimum length are eligible


