Tag Info

Hot answers tagged

13

The two items are not really related. AllowUnsafeUpdates will allow changes to the content database happen on a GET request instead of a POST request. This is a very bad idea. It is very trivial to write a script to perform 1000s of GET requests per minute, which would update your content database with duplicates. The actual use cases for AllowUnSafeUpdates ...


6

You use SPSecurity.RunWithElevatedPrivileges when you have a piece of code which requires higher privileges than currently logged in user. For example, your code wants to check if current user belongs to "Approvers" group and Approvers group is configured such that only members of Approvers group can see the membership. You will need ...


6

I anticipate that your root list has the same event receiver assigned to it, and that causes the recursion. The problem, of course, may be not so obvious, but anyway, to prevent event receiver to fire several times, there is a common practice in SharePoint: just use DisableEventFiring and EnableEventFiring methods. internal void ...


4

Not sure I would use PowerShell for this. Why not use Business Connectivity Service (SP2010) or Business Data Catalog (SP2007) for this? If you need to move data redundantly into a list in SharePoint with certain intervals another option would be SQL Integration Services.


4

Update list item using powershell - $SPAssignment = Start-SPAssignment $SPWeb = Get-SPWeb http://SP -AssignmentCollection $spAssignment Next step is to get the list: $SPList = $SPWeb.Lists["Announcements"] When we have located the list we can retrieve the item. The quickest way is to use the GetItemByID() method: $SPItem = $SPList.GetItemById("1") ...


3

OK, SO I think I solved my problem. I actually had two things going on here: 1) A WCF connection propagates metadata updates on check-in to another web application (ASP.NET). The field I was constantly getting messages about IS required on that site. Wouldn't expect anyone on here to figure that out. I made the field required in SharePoint and set ...


3

The two are totally different things as explained here: AllowUnsafeUpdates vs RunWithElevatedPrivileges http://rameshsps2010.blogspot.co.uk/2011/06/allowunsafeupdates-vs.html AllowUnsafeUpdates Gets or sets a Boolean value that specifies whether to allow updates to the contents database as a result of a GET request or without requiring a security ...


3

The problem is that you are using a filepath that is URL encoded (the %20 should be a space): <Batch OnError="Continue"> <Method ID="1" Cmd="Update"> <Field Name="ID" /> <Field Name="FileRef">http://sharepoint:32667/personal/user/Shared Documents/EmailMessage.msg</Field> <Field ...


2

Given the information I would still chose to do a console app that leverages SharePoint's web services versus using PowerShell with remoting. If you need it to work with both, then I would stick with the soap based services. http://msdn.microsoft.com/en-us/library/ms479390(v=office.12).aspx


2

If your data source is within a site collection, use a Content Query Web Part and filter on the Task content type, or otherwise use SPSiteDataQuery. If it's split across site collections, you can only use search, and the indexing can only occur on a content source, as Anita mentioned.


2

This could be a case where the handle to the list is recreated with each call which would explain why the changes are not persisting. Try this instead : SPList pagesList = publishingWeb.PagesList; pagesList.EnableModeration = false; pagesList.EnableVersioning = true; pagesList.MajorVersionLimit = 10; pagesList.EnableMinorVersions = false; ...


2

You have to roll your own, there isn't anything built in. The closest is a form operation, SPRequireUnique. You'd need to do a GetListItems operation to first see what's in the list, compare it to what you have and either skip it, update it, or add it.


2

Event receivers are generally attached to lists by means of a list definition (which can define event receivers that are attached upon deployment) or programmatically through custom code. Depending on how you're deploying this event receiver, you might not actually be attaching the receiver to your list. You can use PowerShell to see which event receivers ...


1

You need to add a column to the first calendar that stores a unique key of any related item in the team calendar. You could use the SharePoint ID of the first calendar, for example. Add a column to the Team calendar called "ParentID". Let the workflow find an item with that ParentID = current Item ID in the Team calendar. If that item is found, the workflow ...


1

First thing first, Yes you will have to call listItem.Update() reason is because in itemAdded event Item has been added to list already and now you are about to update it. Second, as Paul said you setting item level permissions can be nightmare as they actually effect page's performance while loading it. Third, you might would like to look at this article, ...


1

You can use SPItemEventReceiver to create your own event receiver. In your receiver you can implement ItemUpdating method. In this method you can retrieve item from SPItemEventProperties. Compare item field value with your value and use following code to cancel update: properties.Cancel = true; properties.ErrorMessage = "you can not update this item";


1

mikey, This is not available OOB... What you can do is create a new Custom Action that will add a button to the ribbon right after the Edit button, follow this on making custom action: http://msdn.microsoft.com/en-us/library/hh500259.aspx In custom action, call a Javascript function in which you can get all the items selected by user, see this URL: ...


1

I strongly recommend u start by monitoring menuItems with a debugger, since this is your global variable that stores the Items. At the end you could write some code like this: function saveChanges() { var context = new SP.ClientContext.get_current(); var web = context.get_web(); var list = web.get_lists().getByTitle("ExpenseReportItems"); ...


1

For example, it's not safe to make updates and removal on GET requests, because someone may send you a link, you will click and item will be deleted. Thus it's strongly recommended to make updates on POST requests, thus the error is fired. In some cases it's really required to do and AllowUnsafeUpdates is used. Please see this link and that link for ...


1

I would suggest reviewing Karine Bosch's blog posts series on SharePoint Event Receivers that includes simple Walkthroughs with Document Library Event Receivers.


1

please pay attention to the Task List. The Task lists execute the Workflow really. If you don't finalize the assigned task, your WF not run. This is my code to exceute a task and make te WF continue by the steps: This code it's used ina SP WebPart, with a WorkFlow with two approvers.: SPSecurity.RunWithElevatedPrivileges(delegate() { ...


1

If you want to update a listitem or start a workflow without server side code, then in SP2007 you only option is to use the Web Services. If you want to do it directly in javascript on a form I'd recommend that you use SPServices, which is a jQuery library for SharePoint, that amonst other allow you to update a list item or start a workflow


1

When you modify a list template, the changes are only visible in new list instances you create after the modification. This is by-design. Unfortunately you need to manually modify existing list instances, or create a small application that will loop through all SPWebs and lists on each site, and modify the choices.


1

For the following examples I've created: a site called MySubSite in my sitecollection http://sharepoint. a document library called "My Doc Lib" added a column "FirstName" a folder called "My Folder" uploaded a document called mydoc.txt to both the root and "My folder" The following code finds the mydoc.txt inside "My folder" and changes FirstName. ...


1

try changing your query to this: "<View Scope='RecusrsiveAll'> <Query> <Where> <Eq> <FieldRef Name='Title' /> <Value Type='Text'>test</Value> </Eq> </Where> </Query> </View>" ...


1

You could also use a PowerShell script and Windows Task Scheduler to automate the import. Should be easier than a timerjob and faster to implement. I wrote a similar script here: http://sp2010adminpack.codeplex.com/wikipage?title=Import-DataIntoSharePoint


1

The reason you're seeing this is because of references crossing each other. You say destinationFile is an SPFile. You call destinationFile.Item.SystemUpdate(false). Which is fine. You have to watch though, because SPFile.Item returns a reference to an SPListItem. If you call this twice, you get a different reference to the SPListItem. Therefore, if you ...


1

This is my second answer since question was updated. I was following link provided by @MikeOryszak and I did some testing. This is the PowerShell script that uses SP web service with custom credentials to insert data: $items #ListItem collection $siteUrl = "http://mySite" $fieldsToCopy = @("Title", "SomeOtherField") #fields to copy #Build batch $batch = ...



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