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

The reason I offer both of those languages is that I can achieve what I'm trying to accomplish using either javascript, or C#, but they are completely different languages. I couldn't find any sort of this functionality in the workflows in sharepoint designer.

share|improve this question
add comment

3 Answers 3

up vote 6 down vote accepted

The easiest way to invoke some code on submission (...insert) of a list item it to write an ItemAdded event receiver. The item level event receiver can be registered against a web, list or content type. Here's an example of registering one against a web (...this would fire for an item added to any list or library on the web:

SPEventReceiverDefinition itemAdded = web.EventReceivers.Add();
itemAdded.Type = SPEventReceiverType.ItemAdded;
itemAdded.Assembly = "MyAssemly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=141fe4b547d7494f";
itemAdded.Class = "MyClass";
itemAdded.SequenceNumber = 100;
itemAdded.Update();

And then the event receiver would look something like this:

public class EventReceivers : SPItemEventReceiver
{
    public override void ItemAdded(SPItemEventProperties properties)
    {
       // perform ItemAdded operation
    }
}
share|improve this answer
    
If I can just check one thing with you: Using SequenceNumbers below 10000 is not recommended because Microsoft 'reserved' them for OOTB receivers. I have heard or read about it in the past but right now I cannot find any valid information on the web (except some random forums). –  Vedran Rasol Jul 30 '11 at 22:26
    
I've heard that before, but I'm not aware of any guidance direct from Microsoft on that. There could also conceivably be scenarios where you are doing something where it's absolutely necessary that your event receiver runs first. –  Rob D'Oria Jul 31 '11 at 0:00
add comment

You could use an Event Receiver. From the article:

What is a custom event handler? A custom event handler is a .Net assembly that contains the additional business logic you need to run when the event occurs in SharePoint.

You'll probably need to implement the ItemAdding and/or ItemAdded event(s).

share|improve this answer
add comment

Javascript code can be run but utilizing the PreSaveAction() function. This will allow you to execute any javascript code you need to on the list item submission before the item is commited to the database.

share|improve this answer
add comment

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.