Copied to clipboard

Flag this post as spam?

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


  • lori ryan 199 posts 529 karma points
    May 10, 2018 @ 11:23
    lori ryan
    0

    publishing documenttype of type 'x' exec Store procedure

    Hi

    Unsure if this is possible. When I publish a documenttype of type 'x' is it possible to trigger a store procedure as well? Any help or pointers would be fantastic.

  • Nathan Woulfe 422 posts 1580 karma points MVP 3x c-trib
    May 10, 2018 @ 11:40
    Nathan Woulfe
    100
  • lori ryan 199 posts 529 karma points
    May 10, 2018 @ 11:44
    lori ryan
    0

    Hey Nathan Thank you so much for coming back to me so fast. I will give it a go :-) Lori

  • Dan Diplo 1505 posts 5911 karma points MVP 4x c-trib
    May 10, 2018 @ 11:48
    Dan Diplo
    0

    Does it have to be a stored procedure?

    The simplest way I can think of would be to use the built-in events that can be raised when content is changed - see https://our.umbraco.org/Documentation/Reference/Events/ContentService-Events

    So you can raise an event when content is published, check the doctype alias and then conditionally execute some code. In your case you'd use the ContentPublished event to hook into.

    If you really need to then execute a stored procedure you could do so at this point via code. Umbraco exposes a Database class that you can access via ApplicationContext to run database queries. So it would be something like:

    ApplicationContext.Current.DatabaseContext.Database.Execute(";EXEC spMyProcedure"); See https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/63877-Calling-a-stored-procedure-and-get-results

  • lori ryan 199 posts 529 karma points
    May 14, 2018 @ 08:55
    lori ryan
    0

    works brilliantly Thank you so much for the help Dan Diplo and Nathan Woulfe

  • 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