HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Customize retention policies

Describes how to change the date for a specific submission and how to change the default values through code.



Optimizely Forms is only supported by MVC-based websites and HTML5-compliant browsers.

Editors can set a retention policy in the user interface, that is, control how long finalized form submissions and partially submitted form data should be stored.

Use Actor to change expired date of submission

By default, the retention policy of a form applies to all its submissions. It is possible to write a custom actor to change the date for a specific submission. In this example, we create a custom actor to check if a submission comes from an internal or external visitor. If it comes from an internal user, the expired date is set to the previous day so the submission is deleted right after the Submission Cleanup scheduled job is run.

  1. Create a class that implements the PostSubmissionActorBase and ISyncOrderedSubmissionActor classes.
  2. Implement the class as below:
public class CheckInternalSubmissionActor : PostSubmissionActorBase, ISyncOrderedSubmissionActor
    public int Order => 500;
    public override object Run(object input)
        //get client ip
        var geoDataSource = new GeoVisitorDataSource();
        var geoData = geoDataSource.GetGeoDataAsync().Result;
        //get local ip address
        var localIPList = new List<string>() { "" };
        //check if submission comes from internal address, if yes then set expired date to 
        previous day
        if (localIPList.Contains(geoData.ip))
            var item = SubmissionData;
            item.Data[Constants.SYSTEMCOLUMN_ExpiredDate] = DateTime.UtcNow.AddDays(-1);
        return null;



ExpiredDate should be stored as UTC time format, otherwise it may cause some unexpected issues.

Change default value of retention policies

Optimizely Forms uses SubmissionRetentionService to get the default value for the retention periods of partial and finalized submissions. You can inherit that class and override the method to get a custom default value for the retention periods for submissions. Example:

public class CustomSubmissionRetentionService : SubmissionRetentionService
    /// <summary>
    /// Get default retention period.
    /// <returns>  
    /// A tuple contains 2 items:
    /// Item1: Default retention period (days) value of partial submission.
    /// Item2: Default retention period (days) value of finalized submission.
    /// </returns>
    /// </summary>
    public override Tuple<int, int> GetDefaultRetentionPeriod()
        return Tuple.Create(20, 60);

Then you need to go to DependencyResolverInitialization to register that service:

public void ConfigureContainer(ServiceConfigurationContext context)
    //Implementations for custom interfaces can be registered here.
    context.ConfigurationComplete += (o, e) =>
        //Register custom implementations that should be used in favour of the default 
        context.Services.AddTransient<IContentRenderer, ErrorHandlingContentRenderer>() 
        .AddTransient<ContentAreaRenderer, AlloyContentAreaRenderer>()
        .AddTransient<SubmissionRetentionService, CustomSubmissionRetentionService>();