Converting just a workflow from Contour to Umbraco Forms
HI,
I have two websites, one using contour and one using umbraco forms.I created a Workflow for the contour website with no problems. However, I can't find any documentation on updating worflows from contour to forms. I did find the migration package but since I don't want to migrate the contour site I just want to use my custom workflow from this site on another.
My code follows the same standards, I then build my seperate project and copy the dll to the bin folder for my website. This works on the contour site with no problems but the umbraco forms website the workflow just doesn't appear. I have put my code below if this helps.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using Umbraco.Forms.Data.Storage; using Umbraco.Forms.Core.Services; using Umbraco.Forms.Core; using Umbraco.Forms.Core.Enums; using Umbraco.Forms.Core.Attributes; using System.Xml; using System.Xml.XPath; using umbraco.BusinessLogic;
namespace Contour.Addons.MulitpleEmails { public class MultipleEmails : Umbraco.Forms.Core.WorkflowType { [Umbraco.Forms.Core.Attributes.Setting("MultipleEmails mapping"description = "Setup Emails per selection <br /> (please us ^ to seperate email address)", control = "Contour.Addons.MulitpleEmails.EmailMapper", assembly = "Contour.Addons.MulitpleEmails")] public string scoremappings { get; set; }
[Setting("Message", description = "Enter the intro message", control = "Umbraco.Forms.Core.FieldSetting.TextArea")] public string Message { get; set; }
[Setting("EmailFrom", description = "Email from field alias that contains email address", control = "Umbraco.Forms.Core.FieldSetting.TextField")] public string EmailFrom { get; set; }
public MultipleEmails() { this.Name = "Emails per selection"; this.Id = new Guid("F2V7D107-TY23-99RQ-P843-66M287X63789"); this.Description = "Sends Email per pre-value selection"; }
public override List<Exception> ValidateSettings() { List<Exception> exceptions = new List<Exception>(); return exceptions; }
public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e) { try { //calc score String Email = ""; String subject = "Form has been completed";
Dictionary<String, String> Emails = new Dictionary<String, String>();
foreach (string mapping in scoremappings.Split(';')) { if (!string.IsNullOrEmpty(mapping) && mapping.Split(',').Length > 0) { Emails.Add(mapping.Split(',')[0], mapping.Split(',')[1]); } }
FormStorage fs = new FormStorage(); Form f = fs.GetForm(record.Form); RecordStorage rs = new RecordStorage(); rs.UpdateRecord(record, f); rs.UpdateRecordXml(record, f);
private void SendMail(string to, string subject, string message) { try { var m = new System.Net.Mail.MailMessage { From = new System.Net.Mail.MailAddress(EmailFrom), Subject = subject, IsBodyHtml = true };
foreach (var email in to.Split('^')) { m.To.Add(email); } m.Body = message; var s = new System.Net.Mail.SmtpClient("localhost"); s.Send(m); } catch (Exception ex) { LogError(ex.Message); } } } }
Converting just a workflow from Contour to Umbraco Forms
HI,
I have two websites, one using contour and one using umbraco forms.I created a Workflow for the contour website with no problems. However, I can't find any documentation on updating worflows from contour to forms. I did find the migration package but since I don't want to migrate the contour site I just want to use my custom workflow from this site on another.
Any help much appreciated.
Thanks
Maxi
Hi Maxi,
Perhaps this documentation about extending the workflows in Umbraco Forms with a workflow type can help you https://our.umbraco.org/documentation/Products/UmbracoForms/Developer/Extending/Adding-a-Workflowtype
Hope this helps,
/Dennis
Hi Dennis,
My code follows the same standards, I then build my seperate project and copy the dll to the bin folder for my website. This works on the contour site with no problems but the umbraco forms website the workflow just doesn't appear. I have put my code below if this helps.
Thanks
Maxi
Comment author was deleted
Hey Maxi,
You'll need to update the settings attributes, since those aren't webcontrols anymore but are angularjs views so they will look like this now
[Attributes.Setting("Dirty Words", description ="Comma seperated list of forbidden words", view ="TextField")]
public string DirtyWords { get; set; }
[Attributes.Setting("Action", prevalues ="Delete Record,Approve Record", description ="What to do if it matches", view ="Dropdownlist")]
public string Action { get; set; }
It fetches them from the App_Plugins/UmbracoForms/Backoffice/Common/SettingTypes/ directory
There you'll find all the default ones and those should get you started when you want to create a custom one
is working on a reply...