My work is requiring me to create an event receiver for an itemAdding event for an existing list on a Sharepoint Server. My problem is that while I have access to a Sharepoint Server, I do not have access to the specific server that they want the event receiver on. So I need to copy an event receiver and it's code-behind from one sharepoint server to another.
I created a duplicate of the list on my server (same column names, types, etc.)
I have created an event receiver in Visual Studio 2010 using visual basic that takes the input of a textbox in the NewForm.aspx and adds it to a URL address (example, the hard-coded url address is http://contoso.com/claims?id= and I add the input information to it to create a URL of http://contoso.com/claims?id=1234). This URL is then displayed in a hyperlink column, which can be clicked to go to the URL. I also changed the line in the elements.xml file in the receiver (see below.) It works great on the sharepoint server that I have access to.
Now I need to add this event receiver to the other server.
I am still learning Sharepoint so I am just not sure how a copy of a package works. I was afraid that if I used the deployed package created by VS on my server, that the Site URL in the solution properties would stick. So I changed the Site URL to the server that I don't have access to and only did a build for the solution (not a deployment since I can't deploy to the other server.)
Next I went to the VS Command Prompt, changed to the project directory, and typed "msbuild /t:Package filename.vbproj". This created a .wsp file in the bin/Debug directory of my solution. An admin for the other server copied the .wsp file to it. He added the solution and deployed it (using stsadm -o addsolution -filename filename.wsp and stsadm -o deploysolution -name filename.wsp), but the code-behind does not work. There weren't any error messages. The new list item is added, but the URL is not created or displayed.
What have I done wrong?
EventReceiver1.vb
Public Overrides Sub ItemAdding(properties as SPItemEventProperties)
MyBase.ItemAdding(properties)
Dim baseLink as String = "http://contoso.com?id="
Dim hLink As New SPFieldUrlValue()
hLink.Description = properties.AfterProperties("ReportID").ToString
hLink.Url = baselink & properties.AfterProperties("ReportID").ToString
properties.AfterProperties("URL") = hLink
End Sub
Elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListUrl="Lists/listname">
<Receiver>
<Name>EventReceiver1ItemAdding</Name>
<Type>ItemAdding</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>filename.EventReceiver1</Class>
<SequenceNumber>10000</SequenceNumber>
</Receiver>
</Receivers>
</Elements>
