Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Event Sink Problem Getting Closer

  Asked By: Srikant    Date: Jan 04    Category: Sharepoint    Views: 1362

Using a recommendation from Paul Schaeflein, http://www.schaeflein.net/blog/ , I am able to get the boolean fields from an InfoPath Form. Now my problem is writing the Event to an Event list. After rerading one of Todd Bleeker's post, I creeated a web application to add an Event Item to the list and I added code to set AllowUnsafeUpdates to True as shown below:

Dim site As SPSite = SPControl.GetContextSite(context)
Dim sWeb As SPWeb = site.AllWebs("/sites/Facilities")

Dim destList As SPList = site.AllWebs("/sites/Facilities").Lists("Current Facilities Schedule")

Dim listItems As SPListItemCollection = destList.Items

sWeb.AllowUnsafeUpdates = True
site.AllowUnsafeUpdates = True

Trace.Warn("site URL: " & site.Url)

Trace.Warn("sWeb URL: " & sWeb.Url)

Trace.Warn("site Get: " & site.AllowUnsafeUpdates)

Trace.Warn("sWeb Get: " & sWeb.AllowUnsafeUpdates)

Dim newItem As SPListItem = listItems.Add()

sBegin_date = "12/15/2005"

stitle = "Event Test #" & Now()

sEnd_Date = "12/16/2005"

sRoom_resource = "1735 Conference Room"

sActivity_Type = "Meeting"

newItem("ID") = -1

newItem("fRecurrence") = 0

newItem("Title") = stitle

newItem("Begin") = sBegin_date

newItem("End") = sEnd_Date newItem("Room Resource") = sRoom_resource

newItem("Activity Type") = sActivity_Type

newItem("Approval Status") = 2 'Pending


When I run the web app, I get the following error:

site URL: http://.......................... 0.046588 0.033287
sWeb URL: http://..................../sites/Facilities 0.066538 0.019949
site Get: True 0.066639 0.000102
sWeb Get: True 0.066675 0.000036
Unhandled Execution Error
Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb.
at Microsoft.SharePoint.Library.a.a(String A_0, String A_1, Boolean A_2, Int32& A_3, String& A_4, String A_5, Object& A_6, Object& A_7)
at Microsoft.SharePoint.SPListItem.Update()
Any Ideas on how to fix the problem????



4 Answers Found

Answer #1    Answered By: Kalyan Pujari     Answered On: Jan 04

Do you set  of AllowUnsafeUpdates immediately after getting the object. Don’t continue to reference from the site. Even though many of the SharePoint objects expose collections – they aren’t really collections.

If you do “(site.AllWebs(“/test”) == site.AllWebs(“/test”))” you’ll get back false… So do your site, get your web, set the AllowUnsafeUpdates on it, get your lists from it… you should be all set from there.

Answer #2    Answered By: Katy Patton     Answered On: Jan 04

Still no luck. I moved the statements but still get the error. I have tried vreating a custom .config file per the wssdk, bu tstill no luck.

Answer #3    Answered By: Ana Payne     Answered On: Jan 04

Did you continue to reference the list  like … site.AllWebs(“/blah”).Lists[“MyListName”] … That won’t work.

Answer #4    Answered By: Christop Mcfadden     Answered On: Jan 04

Yes. How should the list  be referenced???

Didn't find what you were looking for? Find more on Event Sink Problem Getting Closer Or get search suggestion and latest updates.