Skip to content

Instantly share code, notes, and snippets.

@PetersonDave
Created October 10, 2013 16:37
Show Gist options
  • Save PetersonDave/6921465 to your computer and use it in GitHub Desktop.
Save PetersonDave/6921465 to your computer and use it in GitHub Desktop.
Formats Sitecore WFFM save action to pull parameters field.
public class FormSaveActionUtilities
{
public static string GetGoogleAnalyticsScriptFromSaveAction(SubmitSuccessArgs args)
{
var googleAnalyticsSubmitActionId = new ID("{617DD7D9-950B-4767-B40A-CEFA848B64C6}");
var script = string.Empty;
var lid = ListDefinition.Parse(args.Form.SaveActions).Groups[0].ListItems;
if (lid == null) return script;
var items = lid.Select(item => args.Form.Database.GetItem(item.ItemID));
var actions = items.Where(command => command != null)
.Select(command => new ActionItem(command))
.ToList();
var googleAnalyticsAction = actions.FirstOrDefault(action => action.ID == googleAnalyticsSubmitActionId);
if (googleAnalyticsAction != null)
{
script = string.Format(googleAnalyticsAction.Parameters, args.Form.Name);
}
return script;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment