Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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>
share|improve this question

1 Answer 1

Im presuming the guy cant debug the code? so you can know that the class is being triggered? the only other thing i could think of is the assembly and class name are they the same as your .vb class?

http://stackoverflow.com/questions/561835/how-do-you-bound-an-event-receiver-to-a-specific-custom-content-type

hope this guides you into the right direction!

share|improve this answer
    
The admin for the server has no coding experience. They have made the site with basic SharePoint knowledge. I wish I had access to it so I could debug the problems! And yes, the assembly and class names are correct. I was so worried about the naming of everything that I've double and triple checked it. My main question was whether or not I've missed anything. Did I copy it all to the other server correctly? Was there a setting that I don't know about that needs to be set? Did I miss something in my code? An additional problem is that they will not put VS2010 on the SP2010 Server. –  Susie Q Sep 4 '12 at 21:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.