Copied to clipboard

Flag this post as spam?

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


  • Steve Morgan 1278 posts 4216 karma points c-trib
    Feb 11, 2015 @ 19:52
    Steve Morgan
    0

    Umbraco Forms - Adding a Custom Workflow

    I've just gone through the documentation on Umbraco Forms (even creating a pull request to fix typos and update a couple of bits) but I'm not sure what I've come up with on creating a Workflow is correct.

    The documentation is here:

    https://our.umbraco.org/Documentation/Products/UmbracoForms/Developer/Extending/Adding-a-Workflowtype

    The code there looks to be either a bit out of date or I'm missing some using directives (or both) as it doesn't seem to work. I suspect it's out of date as it uses Log.Add rather than Umbraco.Core.Logging.LogHelper. Also the RecordService doesn't seem to accept a parameter now (I've modified this by passing the record and form in the delete method.. though there doesn't seem to be a Dispose method).

    Basically is what I've come up with correct or bat-muck crazy?  After all this messing around my solution builds but when I try to add the workflow an exception is thrown about WorkflowController.cs not found?

    Has anyone got any tips on this please?

    Steve

  • Steve Morgan 1278 posts 4216 karma points c-trib
    Feb 11, 2015 @ 19:53
    Steve Morgan
    0
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Umbraco.Forms.Core;
    using Umbraco.Forms.Core.Enums;
    using Umbraco.Core.Logging;
    using Umbraco.Forms.Data;
    using Umbraco.Forms.Data.Storage;
    using Umbraco.Forms.Core.Services;
    using Umbraco.Forms.Web.Services;
    
    namespace FormsTest.App_Code
    {
        public class TestFormWorkflow : Umbraco.Forms.Core.WorkflowType
        {
            public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
            {
                // first we log it
                Umbraco.Core.Logging.LogHelper.Info(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "the IP " + record.IP + " has submitted a record");
                // we can then iterate through the fields
                foreach (RecordField rf in record.RecordFields.Values) 
                {
                    // and we can then do something with the collection of values on each field
                    List<object> vals = rf.Values;
    
                    // or just get it as a string
                    rf.ValuesAsString();
                }
    
                // If we altered a field, we can save it using the record storage
                RecordStorage store = new RecordStorage();
                store.UpdateRecord(record, e.Form);
                store.Dispose();
    
                // we then invoke the recordservice which handles all record states //and make the service delete the record.
                RecordService rs = new RecordService();
                rs.Delete(record, e.Form);
                //rs.Dispose(record, e.Form);
    
                return WorkflowExecutionStatus.Completed;
            }
    
            public override List<Exception> ValidateSettings()
            {
                throw new NotImplementedException();
            } 
        }
    }
  • Vivek 2 posts 73 karma points
    Oct 10, 2015 @ 14:49
    Vivek
    1

    Hi Steve,

    I am also facing same issue. Were you able to resolve this.

    ~Vivek

  • Marc Love (uSkinned.net) 349 posts 946 karma points
    Oct 20, 2015 @ 15:54
  • 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