Copied to clipboard

Flag this post as spam?

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


  • Lewis Smith 211 posts 620 karma points c-trib
    Feb 27, 2019 @ 10:01
    Lewis Smith
    0

    Overriding forms sending email method

    Hi all,

    I have installed Umbraco forms and i need up override the default sending email method as I would like to use Hangfire, and also need to do some other stuff on submission of a form.

    I have tried creating a controller which inherits UmbracoFormsController and then created on override for every method, put a break point in these and then submitted a form, none of these break points were hit.

    Where am i going wrong/ could someone point me in the right direction?

    The site is running 7.13.2 assembly: 1.0.6974.19955

    Form version 7.0.6

    Here is the code i have currently:

    public class UmbracoFormsOverrideController : UmbracoFormsController
    {
        protected override IAsyncResult BeginExecute(RequestContext requestContext, AsyncCallback callback, object state)
        {
            return base.BeginExecute(requestContext, callback, state);
        }
        protected override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            base.OnResultExecuted(filterContext);
        }
        protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
        {
            return base.BeginExecuteCore(callback, state);
        }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
        }
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);
        }
        protected override void OnAuthentication(AuthenticationContext filterContext)
        {
            base.OnAuthentication(filterContext);
        }
        protected override void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
        {
            base.OnAuthenticationChallenge(filterContext);
        }
        protected override void OnAuthorization(AuthorizationContext filterContext)
        {
            base.OnAuthorization(filterContext);
        }
        protected override void OnException(ExceptionContext filterContext)
        {
            base.OnException(filterContext);
        }
        protected override void OnFormHandled(Form form, FormViewModel model)
        {
            base.OnFormHandled(form, model);
        }
        protected override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            base.OnResultExecuting(filterContext);
        }
    }
    

    Thanks, Lewis

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Feb 27, 2019 @ 10:13
    Matthew Wise
    100

    Hi Lewis,

    Instead of overriding the default controller. I would suggest creating a custom workflow - https://our.umbraco.com/documentation/Add-ons/UmbracoForms/Developer/Extending/Adding-a-Workflowtype

    You can then remove the default send email and use your own workflow in its place via the UI

    Matt.

  • Lewis Smith 211 posts 620 karma points c-trib
    Feb 27, 2019 @ 10:37
    Lewis Smith
    0

    Hi Matthew,

    I have just tried this, is it possible that all forms run through this custom workflow?

    Do i have to choose this workflow on the form somehow or does the ID put in the constructor have to match the ID of the form?

    public class UmbracoFormsOverrideController : WorkflowType
    {
        public UmbracoFormsOverrideController()
        {
            this.Name = "Custom Workflow";
            this.Id = new Guid("07aaf56e-e988-4c9e-9206-a99cd80dcdbe");
            this.Description = "This will send an email using hangfire instead of default email provider.";
            this.Icon = "icon-chat-active";
            this.Group = "Hangfire";
        }
        public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
        {
            return WorkflowExecutionStatus.Completed;
        }
        public override List<Exception> ValidateSettings()
        {
            return new List<Exception>();
        }
    }
    

    I am calling the form using:

    @Umbraco.RenderMacro("renderUmbracoForm", new { FormGuid = "07aaf56e-e988-4c9e-9206-a99cd80dcdbe", FormTheme = "bootstrap3-horizontal", ExcludeScripts = "1" })
    

    This is what I have now, when loading the page with the form it hits the constructor but when submitting the form both methods are not hit...

    Thanks, Lewis

  • Lewis Smith 211 posts 620 karma points c-trib
    Feb 27, 2019 @ 10:40
    Lewis Smith
    0

    Hi Matthew,

    Okay i found where i add the custom workflow, so i understand now.

    Thanks for you help!

    Lewis

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Feb 27, 2019 @ 10:41
    Matthew Wise
    0

    Glad you found it :)

  • 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.

    Continue discussion

Please Sign in or register to post replies