2

I'm using Sitecore 9.0.1 and using the default Save Data submit action on my form:

save data submit action

There are many garbage entries due to test and bot submissions, and there isn't a way to delete any of the entries.

Sitecore 9.3 appears to offer deletion functionality, although it is limited; only supporting deletion of all entries and entries for a specified date range.

We have been using Sitecore PowerShell Extensions to allow users to view the form entries within Sitecore itself, thanks to these Forms Data Viewer SPE scripts. The scripts ultimately leverage the Show-ListView SPE function to display and export the data like so:

Sitecore Forms entries list view

Now I just need to make the final leap and allow individual entries to be deleted. Any ideas about how I can approach this? It's not clear to me because the data listed in the table doesn't correspond to items, so it's not as simple as doing a simple delete via SPE.

I've done some digging to see what Sitecore.Experience.Forms.Data provides in terms of functionality. Here's a decompilation:

using Sitecore.ExperienceForms.Data.Entities;
using System;
using System.Collections.Generic;

namespace Sitecore.ExperienceForms.Data
{
    public interface IFormDataProvider
    {
        void CreateEntry(FormEntry entry);

        void DeleteEntries(Guid formId);

        IReadOnlyCollection<FormEntry> GetEntries(Guid formId, DateTime? startDate, DateTime? endDate);
    }
}

Unfortunately it doesn't look like it provides an interface for deleting specific entries. It's all or nothing (at least on Sitecore version 9.0.1.). The question now becomes how can I see what's in DeleteEntries and how can I extend the IFormDataProvider to add the necessary functionality? From there I should be able to write the necessary PowerShell script for the list view action.

Another option seems to be to run SQL directly on the form entry table. Then it becomes a question of how to plug and play that with SPE via a custom action within the list view.

2
  • If you want to see what DeleteEntries exactly does, you'll need to compile the relevant DLL. Use DotPeek or similar.
    – Kasaku
    Commented Apr 8, 2020 at 23:03
  • @Kasaku it doesn't seem possible to decompile the code; only the interface. Commented Feb 16, 2023 at 17:09

1 Answer 1

1

Without customization, it is not possible to do this on your version of Sitecore Forms.

If using Sitecore.ExperienceForms version 4 which ships with SC 9.3 (and perhaps some earlier versions), the following approach may work:

$formId = "{00000000-0000-0000-0000-000000000000}" # your form Item ID
$serviceType = [Sitecore.ExperienceForms.Data.IFormDataProvider]
$service = [Sitecore.DependencyInjection.ServiceLocator]::ServiceProvider.GetService($serviceType) -as $serviceType

# Use highly specific date times to single out individual entries
$startDate = [datetime]::Parse("2022-01-01 00:00:00")
$endDate = [datetime]::Parse("2022-01-01 00:01:00")

$service.DeleteEntries($formId, $startDate, $endDate)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.