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.
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:
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.
Hi Lori
Sounds like this might be useful -> https://our.umbraco.org/documentation/Reference/Events/ContentService-Events
N
Hey Nathan Thank you so much for coming back to me so fast. I will give it a go :-) Lori
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
works brilliantly Thank you so much for the help Dan Diplo and Nathan Woulfe
is working on a reply...