I didn't see much in the documentation on this (the new stuff), but how do I add some logic to all forms. I am looking into building a system that needs to do some processing that is common across every single form that is created through the GUI and am not even sure where to start.
Contour Form - Event or Logic on All forms
I didn't see much in the documentation on this (the new stuff), but how do I add some logic to all forms. I am looking into building a system that needs to do some processing that is common across every single form that is created through the GUI and am not even sure where to start.
Thanks in advance.
I thought I had figured this out but I can't seem to find a way to set a default workflow other than the built in one.
Comment author was deleted
there is a form created event you can hook into
Comment author was deleted
look at FormStorage FormCreated
Comment author was deleted
on the create workflow
you'll need workflow storage
Comment author was deleted
here is a workflow snippet from the codefirst stuff
//workflows
WorkflowStorage ws = new WorkflowStorage();
int l = 0;
foreach (var workflow in ((FormBase)Activator.CreateInstance(typeForm)).Workflows)
{
var workflowAttr = FormManager.GetWorkflowAttribute(workflow.GetType());
Workflow wf;
var wfs = ws.GetAllWorkFlows(form);
if (wfs.Any(x => x.Name == workflowAttr.Name))
wf = wfs.Single(x => x.Name == workflowAttr.Name);
else
wf = new Workflow();
wf.Name = workflowAttr.Name;
wf.ExecutesOn = workflowAttr.ExecutesOn;
wf.SortOrder = l;
wf.Type = workflow.Type;
wf.Active = workflowAttr.Active;
wf.Form = form.Id;
wf.Settings = new Dictionary<string, string>();
foreach (var propInfo in workflow.Type.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
{
var settingAttr = Util.GetAttribute<Umbraco.Forms.Core.Attributes.Setting>(propInfo);
if (settingAttr == null)
continue; // skip this property - not part of a document type
wf.Settings.Add(propInfo.Name, propInfo.GetValue(workflow.Type, null).ToString());
}
if (wf.Id == Guid.Empty)
ws.InsertWorkflow(wf);
else
ws.UpdateWorkflow(wf);
l++;
}
ws.Dispose();
Comment author was deleted
and this is how we add the default workflow
string email = umbraco.BasePages.UmbracoEnsuredPage.CurrentUser.Email;
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 = form.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 " + form.Name + " was submitted");
wfSettings.Add("Message",
"the form " + form.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);
}
is working on a reply...