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 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?
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();
}
}
}
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
Hi Steve,
I am also facing same issue. Were you able to resolve this.
~Vivek
I found this on Stackoverflow which works.
http://stackoverflow.com/questions/28431623/umbraco-7-2-forms-not-contour-customize-the-email-work-flow
is working on a reply...