Here is an example of a send to an email that is entered by the user in the form workflow:
The email service is just a method in our repository which sends off an email using the Xslt file specified in the properties but this shows being able to get the value of a field out in a workflow in XML format.
using System;
using System.Collections.Generic;
using Umbraco.Forms.Core;
using Umbraco.Forms.Core.Enums;
using Umbraco.Forms.Data.Storage;
using System.Xml;
using Umbraco.Forms.Core.Attributes;
using System.Web;
using QHotels.Services;
using System.Text.RegularExpressions;
using System.IO;
public class SendEmailToUser : WorkflowType
{
// Generates the new workflow details for Contour in the workflow dropdown in Contour
public SendEmailToUser()
{
// Need to generate a new guid for the new custom workflow - add your own GUID
this.Id = new Guid("6E638E92-0F61-493c-A1AE-DED9D3F3333A");
this.Name = "Send User Email";
this.Description = "If you want to send an email to a field entered in the form";
}
[Setting("Email Look Up Field", description = "Enter the receiver email lookup field", control = "Umbraco.Forms.Core.FieldSetting.TextField")]
public string EmailLookUpField { get; set; }
[Setting("Xslt File", description = "The name of the file within the XSLT folder that will be the email template", control = "Umbraco.Forms.Core.FieldSetting.TextField")]
public string XsltFile { get; set; }
[Setting("Email Subject", description = "Subject of the email", control = "Umbraco.Forms.Core.FieldSetting.TextField")]
Retrieving form values in a workflow
Quick question.... is the only way to access a contour form value in a workflow to use the [# ] notation and retrieve a request collection value?
Here is an example of a send to an email that is entered by the user in the form workflow:
The email service is just a method in our repository which sends off an email using the Xslt file specified in the properties but this shows being able to get the value of a field out in a workflow in XML format.
Hi Paul,
I use a quick (and dirty) helper method to grab content of a form field by field caption
public static RecordField GetByLabel(this Record record, string labelName)
{
return record.RecordFields.Values.Where(value => value.Field.Caption == labelName).FirstOrDefault();
}
You already have the record from the public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
Can use the ValuesAsString() method on the returned record field to get a string value e.g.
string recipient = CogFormHelpers.GetByLabel(record, EmailFieldLabel).ValuesAsString();
where EmailFieldLabel is the caption of the email field e.g. "Email Address"
Tom
is working on a reply...