Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Still Can't Get EventSink To Work.

  Asked By: Alexandria    Date: Apr 17    Category: Sharepoint    Views: 795

I still can't get the Event Handler to add an item to the Event list. I added site.AllowUnsafeUpdates = True as well as creating a custom configuration file based on the WSSSDK articlel on Code Access Security for Administrators to add the following:

<IPermission class="SharePointPermission"
Still no luck. Anyone??? Here is the pertinent code:

Case SPListEventType.Insert
'Perform necessary actions for the Insert event
Dim uri As New System.Uri(SharePointWeb.Url)

Dim virtualServer As SPVirtualServer = globalAdmin.OpenVirtualServer(uri)
Dim siteCollections As SPSiteCollection = virtualServer.Sites
Dim url As String = "http://........./sites/facilities"
Dim siteCollection As New SPSite(url)
Dim site As SPWeb
site.AllowUnsafeUpdates = True
site = siteCollection.AllWebs("Facilities")

Dim destList As SPList = site.Lists("Current Facilities Schedule")
sLog = sLog + " <destList.ID>: " + destList.ID.ToString + vbCrLf + vbCrLf
sLog = sLog + " <allowUnsafeUpdates>: " + site.AllowUnsafeUpdates.ToString + vbCrLf + vbCrLf
Dim listItems As SPListItemCollection = destList.Items
Dim newItem As SPListItem = listItems.Add()

newItem("ID") = -1
newItem("fRecurrence") = 0
newItem("Title") = stitle
newItem("Created") = sCreated.ToString("yyyy-MM-dd") + "T00:00:00Z"
newItem("Created By") = sCreatedBy
newItem("Modified") = sModified.ToString("yyyy-MM-dd") + "T00:00:00Z"
newItem("Modified By") = sModifiedBy
newItem("Begin") = sBegin_date.ToString("yyyy-MM-dd") + "T00:00:00Z"
newItem("End") = sEnd_Date.ToString("yyyy-MM-dd") + "T00:00:00Z"
newItem("Room Resource") = sRoom_resource
newItem("Activity Type") = sActivity_Type
newItem("Comments") = scomments

newItem("Approval Status") = 2 'Pending


'End If
sLog = sLog + "sInstructor_PC = <" + sInstructor_PC + "> " + vbCrLf
sLog = sLog + "sRoom_resource = <" + sRoom_resource + "> " + vbCrLf
EventLog.WriteEntry("Facilities Event Log ", sLog, EventLogEntryType.Information, listEvent.Type)

Case SPListEventType.Invalid
'Perform necessary actions for the Invalid event



5 Answers Found

Answer #1    Answered By: Mary Adams     Answered On: Apr 17

Is the assembly in the GAC (required for EventSink assemblies)? Is the
Event list  you are trying to add  to in the same Web as the Document
Library that is generating the event?

Answer #2    Answered By: Laura Walker     Answered On: Apr 17

The FacilitiesEvent.dll is in the GAC, adding an entry to the Appliction
Event log  works. The InfoPath form is in the /sites/facilities/request form
library and the Event list  displayson the Qucik Launch Bar ass Current
Facilities Schedule but when you click on the link it goews to

When you go to Documents and Lists it shows under Lists as Current
Facilities Schedule

Answer #3    Answered By: Alyssa Butler     Answered On: Apr 17

In the GAC and in the same Web... Hmmm, this should work. When a form is
inserted into the Request form library you want to create an new
listitem in the Event list, correct?

What is the exact error?

Answer #4    Answered By: Katy Patton     Answered On: Apr 17

That's the problem, there is no error the item  just doesn't get added.
Robert L. Bogue suggested set of AllowUnsafeUpdates immediately after
getting the object and not to access  the list  using site  =
siteCollection.AllWebs("Facilities").Lists("Current Facilities Schedule")

The only indication of something wrong is that the Event log  entry does not
show the results of sLog = sLog + " <destList.ID>: " + destList.ID.ToString
+ vbCrLf + vbCrLf even though is does show sLog = sLog + "
<allowUnsafeUpdates>: " + site.AllowUnsafeUpdates.ToString + vbCrLf + vbCrLf
as <allowUnsafeUpdates>: True

Answer #5    Answered By: Ana Payne     Answered On: Apr 17

I'm not sure how to help you. If you post whole your class, I
will try it out in my environment.

Didn't find what you were looking for? Find more on Still Can't Get EventSink To Work. Or get search suggestion and latest updates.