Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Fredrik 89 posts 108 karma points
    Mar 10, 2011 @ 16:38
    Fredrik
    0

    event if document is moved

    Hi,

    I have the following structure

    Customers

          -Customer1

          -Customer2 etc...

    Unhandeled customers

          -Customer1

          -Customer2 etc...

     

    When a customer fills in a form to become customer they are automatically placed under unhandeled customers node.

    A business unit then fills in a few more properties on the customer before moving it to the Customer node.

    I want to fire some kind of event when this happens and send a mail to the customer. How can it be achieved?

  • kows 81 posts 151 karma points c-trib
    Mar 10, 2011 @ 16:48
    kows
    1

    you just need to write a class for that:

    public class DocumentEvent : ApplicationBase

    add a handler to umbraco.cms.businesslogic.web.Document.AfterMove .

    Check inside the handler if parent is Customers and then you can send mail.

  • Fredrik 89 posts 108 karma points
    Mar 10, 2011 @ 22:35
    Fredrik
    0

    Ok, that sounds really smooth and easy. Where do I write this class? Where do I place it so to speak?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 10, 2011 @ 22:39
    Tom Fulton
    0

    Hi,

    You'd be writing the class in Visual Studio...compile and copy the DLL to /bin/.

    Here's some links to get started with sample code:

    Wiki:  Using ApplicationBase to register events

    Richard Soeteman also had a good blog post about events

    Hope this helps,
    Tom

  • Fredrik 89 posts 108 karma points
    Mar 11, 2011 @ 10:10
    Fredrik
    0

    What eventhandler should I use for the AfterMove? PublishEventHandler, RollBackEventHandler..etc...

  • Fredrik 89 posts 108 karma points
    Mar 11, 2011 @ 10:16
    Fredrik
    0

    Never mind my last post :)

  • Fredrik 89 posts 108 karma points
    Mar 11, 2011 @ 10:26
    Fredrik
    0

    Heres a problem though :)

    Sender does not contain Id property...I can only find the following methods in sender as commented below

    namespace AutoMoveCustomer
    {
        public class AutoMoveCustomerHandler : ApplicationBase
        {
            public AutoMoveCustomerHandler()
            {
                Document.AfterMove += new EventHandler<MoveEventArgs>(Document_AfterMove);
            }
            void Document_AfterMove(object sender, MoveEventArgs e)
            {
                /*
                sender.Equals();
                sender.GetHashCode();
                sender.GetType();
                sender.ToString():
                */
            }
        
        }
    }
  • kows 81 posts 151 karma points c-trib
    Mar 11, 2011 @ 11:03
    kows
    0

    try casting sender to Document or CMSNode, then id should be accessible.

  • Fredrik 89 posts 108 karma points
    Mar 11, 2011 @ 11:59
    Fredrik
    0

    Thanks guys!

     

    New problems :)

    Error 1 The type 'umbraco.interfaces.IApplication' is defined in an assembly that is not referenced. You must add a reference to assembly 'interfaces, Version=1.0.3931.19861, Culture=neutral, PublicKeyToken=null'. C:\Projects\AutoMoveCustomer\AutoMoveCustomer\AutoMoveCustomerHandler.cs 13 18 AutoMoveCustomer

  • kows 81 posts 151 karma points c-trib
    Mar 11, 2011 @ 12:24
    kows
    0

    get interfaces.dll out of the bin map of your site and add a reference to it in your project

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies