Copied to clipboard

Flag this post as spam?

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


  • Ryan McCullough 3 posts 23 karma points
    Mar 19, 2012 @ 20:45
    Ryan McCullough
    0

    Workflow templates?

    We have some form templates, and would like each form created from these templates to share the same workflow setup. Right now, we can easily create copies of the form, but must manually go in and recreate all of the workflows afterwards. Is there any way to get workflows into a template, or should I start hacking up the form creation code?

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Mar 21, 2012 @ 08:43
    Tim Geyssens
    0

    Hey,

    We'll add this to the todo list but won' be for a couple of weeks untill we can add this...

    By hooking into the form event model you should be able to add a workflow

    The event you need to use is:

     FormStorage.FormCreated

    Here is an example (is used to attached the email workflow on form creation)

            public static void AttachEmailWorkflow(Form f)
            {
                WorkflowStorage workflowStorage = new WorkflowStorage();
                //setup a standard workflow to send off emails when the form is submitted
                string email = ProviderManager.Instance.UmbracoContextProvider.GetCurrentUserEmail();
    
                if (!string.IsNullOrEmpty(email))
                {
                    Workflow wf = Workflow.Create();
                    wf.ExecutesOn = Umbraco.Forms.Core.Enums.FormState.Submitted;
                    wf.Name = "Send email to " + email + " when submitted";
                    wf.Form = f.Id;
                    wf.Active = true;
                    wf.Type = Umbraco.Forms.Core.Providers.WorkflowTypeProviderCollection.Instance.GetProvider(new Guid("E96BADD7-05BE-4978-B8D9-B3D733DE70A5"));
                    Dictionary<string, string> wfSettings = new Dictionary<string, string>();
    
                    wfSettings.Add("Email", email);
                    wfSettings.Add("Subject", "the form " + f.Name + " was submitted");
                    wfSettings.Add("Message", "the form " + f.Name + " was submitted, this is the list of values it contained, you can turn this email off under workflows in Umbraco Contour");
    
                    wf.Settings = wfSettings;
    
                    workflowStorage.InsertWorkflow(wf);
                }
            }
  • Ryan McCullough 3 posts 23 karma points
    Mar 28, 2012 @ 22:05
    Ryan McCullough
    0

    Hi, Tim. That would be great if it could be added as a feature. Has it been added to the todo list? If so, do you have an ETA? I will attempt to do it myself, but would rather not duplicate your efforts if you plan on completing it soon.

    Thanks.

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Mar 29, 2012 @ 13:40
    Tim Geyssens
    0

    Well main focus is on the v5 version currently, wich is due in the next weeks, to add this an ETA would be first half of May

  • 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