Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Greg Fyans 140 posts 342 karma points
    Feb 10, 2022 @ 15:34
    Greg Fyans
    0

    Saving multi-page form data against Member (v9 thread)

    There is a 54-reply long thread here on the subject - https://our.umbraco.com/forum/umbraco-forms/87608-multi-page-form-save-data - but this covers Umbraco 7 & 8 mostly, so I thought I'd created a separate thread for v9 chat on the topic.

    I was hoping that this would be a little easier in v9, with events being handled by Notifications, but I've hooked up all the Forms notifications to handlers and as far as I can tell, moving between pages isn't something that's supported by a Notification.

    If you're interested in what all the Forms notifications here, I've put the code at the bottom of this post to save you some time finding them.

    All I want to do is:

    • Logged in Member opens a Form
    • Member completes a page and clicks to move to the next page
    • Progress is saved against this member record (repeat for each page)
    • Member leaves the site for an unspecified amount of time
    • Member returns, opens the form and their state is restored
    • Member completes and submits the form

    Is the method outlined in the thread above still the way to do it? Replacing the whole Forms Surface Controller seems like a sledgehammer approach for this.

    I'm hoping someone has a better method for v9.

    Here's the Notification code...

    using Umbraco.Cms.Core.Events;
    using Umbraco.Forms.Core.Services.Notifications;
    
    namespace My.Notifications
    {
        public class DataSourceSavingNotificationHandler : INotificationHandler<DataSourceSavingNotification>
        {
            public void Handle(DataSourceSavingNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    
        public class FolderCreatedNotificationHandler : INotificationHandler<FolderCreatedNotification>
        {
            public void Handle(FolderCreatedNotification notification)
            {
                var thing = notification.CreatedEntity;
            }
        }
    
        public class FolderCreatingNotificationHandler : INotificationHandler<FolderCreatingNotification>
        {
            public void Handle(FolderCreatingNotification notification)
            {
                var thing = notification.CreatedEntity;
            }
        }
    
        public class FolderDeletedNotificationHandler : INotificationHandler<FolderDeletedNotification>
        {
            public void Handle(FolderDeletedNotification notification)
            {
                var thing = notification.DeletedEntities;
            }
        }
    
        public class FolderDeletingNotificationHandler : INotificationHandler<FolderDeletingNotification>
        {
            public void Handle(FolderDeletingNotification notification)
            {
                var thing = notification.DeletedEntities;
            }
        }
    
        public class FolderSavedNotificationHandler : INotificationHandler<FolderSavedNotification>
        {
            public void Handle(FolderSavedNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    
        public class FolderSavingNotificationHandler : INotificationHandler<FolderSavingNotification>
        {
            public void Handle(FolderSavingNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    
        public class FormCreatedNotificationHandler : INotificationHandler<FormCreatedNotification>
        {
            public void Handle(FormCreatedNotification notification)
            {
                var thing = notification.CreatedEntity;
            }
        }
    
        public class FormCreatingNotificationHandler : INotificationHandler<FormCreatingNotification>
        {
            public void Handle(FormCreatingNotification notification)
            {
                var thing = notification.CreatedEntity;
            }
        }
    
        public class FormDeletedNotificationHandler : INotificationHandler<FormDeletedNotification>
        {
            public void Handle(FormDeletedNotification notification)
            {
                var thing = notification.DeletedEntities;
            }
        }
    
        public class FormDeletingNotificationHandler : INotificationHandler<FormDeletingNotification>
        {
            public void Handle(FormDeletingNotification notification)
            {
                var thing = notification.DeletedEntities;
            }
        }
    
        public class FormPrePopulateNotificationHandler : INotificationHandler<FormPrePopulateNotification>
        {
            public void Handle(FormPrePopulateNotification notification)
            {
                var thing = notification.Form;
            }
        }
    
        public class FormSavingNotificationHandler : INotificationHandler<FormSavingNotification>
        {
            public void Handle(FormSavingNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    
        public class FormSavedNotificationHandler : INotificationHandler<FormSavedNotification>
        {
            public void Handle(FormSavedNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    
        public class FormValidateNotificationHandler : INotificationHandler<FormValidateNotification>
        {
            public void Handle(FormValidateNotification notification)
            {
                var thing = notification.Form;
            }
        }
    
        public class PrevalueSourceCreatedNotificationHandler : INotificationHandler<PrevalueSourceCreatedNotification>
        {
            public void Handle(PrevalueSourceCreatedNotification notification)
            {
                var thing = notification.CreatedEntity;
            }
        }
    
        public class PrevalueSourceCreatingNotificationHandler : INotificationHandler<PrevalueSourceCreatingNotification>
        {
            public void Handle(PrevalueSourceCreatingNotification notification)
            {
                var thing = notification.CreatedEntity;
            }
        }
    
        public class PrevalueSourceDeletedNotificationHandler : INotificationHandler<PrevalueSourceDeletedNotification>
        {
            public void Handle(PrevalueSourceDeletedNotification notification)
            {
                var thing = notification.DeletedEntities;
            }
        }
    
        public class PrevalueSourceDeletingNotificationHandler : INotificationHandler<PrevalueSourceDeletingNotification>
        {
            public void Handle(PrevalueSourceDeletingNotification notification)
            {
                var thing = notification.DeletedEntities;
            }
        }
    
        public class PrevalueSourceSavedNotificationHandler : INotificationHandler<PrevalueSourceSavedNotification>
        {
            public void Handle(PrevalueSourceSavedNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    
        public class PrevalueSourceSavingNotificationHandler : INotificationHandler<PrevalueSourceSavingNotification>
        {
            public void Handle(PrevalueSourceSavingNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    
        public class RecordApprovedNotificationHandler : INotificationHandler<RecordApprovedNotification>
        {
            public void Handle(RecordApprovedNotification notification)
            {
                var thing = notification.Form;
            }
        }
    
        public class RecordCreatingNotificationHandler : INotificationHandler<RecordCreatingNotification>
        {
            public void Handle(RecordCreatingNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    
        public class RecordDeletedNotificationHandler : INotificationHandler<RecordDeletedNotification>
        {
            public void Handle(RecordDeletedNotification notification)
            {
                var thing = notification.Form;
            }
        }
    
        public class RecordDeletingNotificationHandler : INotificationHandler<RecordDeletingNotification>
        {
            public void Handle(RecordDeletingNotification notification)
            {
                var thing = notification.DeletedEntities;
            }
        }
    
        public class RecordFetchingNotificationHandler : INotificationHandler<RecordFetchingNotification>
        {
            public void Handle(RecordFetchingNotification notification)
            {
                var thing = notification.State;
            }
        }
    
        public class RecordSavingNotificationHandler : INotificationHandler<RecordSavingNotification>
        {
            public void Handle(RecordSavingNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    
        public class RecordStateChangeNotificationHandler : INotificationHandler<RecordStateChangeNotification>
        {
            public void Handle(RecordStateChangeNotification notification)
            {
                var thing = notification.Form;
            }
        }
    
        public class RecordSubmittedNotificationHandler : INotificationHandler<RecordSubmittedNotification>
        {
            public void Handle(RecordSubmittedNotification notification)
            {
                var thing = notification.Form;
            }
        }
    
        public class WorkflowCreatedNotificationHandler : INotificationHandler<WorkflowCreatedNotification>
        {
            public void Handle(WorkflowCreatedNotification notification)
            {
                var thing = notification.CreatedEntity;
            }
        }
    
        public class WorkflowCreatingNotificationHandler : INotificationHandler<WorkflowCreatingNotification>
        {
            public void Handle(WorkflowCreatingNotification notification)
            {
                var thing = notification.CreatedEntity;
            }
        }
    
        public class WorkflowDeletedNotificationHandler : INotificationHandler<WorkflowDeletedNotification>
        {
            public void Handle(WorkflowDeletedNotification notification)
            {
                var thing = notification.DeletedEntities;
            }
        }
    
        public class WorkflowDeletingNotificationHandler : INotificationHandler<WorkflowDeletingNotification>
        {
            public void Handle(WorkflowDeletingNotification notification)
            {
                var thing = notification.DeletedEntities;
            }
        }
    
        public class WorkflowExecutionCancelledNotificationHandler : INotificationHandler<WorkflowExecutionCancelledNotification>
        {
            public void Handle(WorkflowExecutionCancelledNotification notification)
            {
                var thing = notification.State;
            }
        }
    
        public class WorkflowExecutionCompletedNotificationHandler : INotificationHandler<WorkflowExecutionCompletedNotification>
        {
            public void Handle(WorkflowExecutionCompletedNotification notification)
            {
                var thing = notification.State;
            }
        }
    
        public class WorkflowExecutionFailedNotificationHandler : INotificationHandler<WorkflowExecutionFailedNotification>
        {
            public void Handle(WorkflowExecutionFailedNotification notification)
            {
                var thing = notification.State;
            }
        }
    
        public class WorkflowExecutionNotConfiguredNotificationHandler : INotificationHandler<WorkflowExecutionNotConfiguredNotification>
        {
            public void Handle(WorkflowExecutionNotConfiguredNotification notification)
            {
                var thing = notification.State;
            }
        }
    
        public class WorkflowExecutionStartedNotificationHandler : INotificationHandler<WorkflowExecutionStartedNotification>
        {
            public void Handle(WorkflowExecutionStartedNotification notification)
            {
                var thing = notification.State;
            }
        }
    
        public class WorkflowSavedNotificationHandler : INotificationHandler<WorkflowSavedNotification>
        {
            public void Handle(WorkflowSavedNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    
        public class WorkflowSavingNotificationHandler : INotificationHandler<WorkflowSavingNotification>
        {
            public void Handle(WorkflowSavingNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    
        public class DataSourceCreatedNotificationHandler : INotificationHandler<DataSourceCreatedNotification>
        {
            public void Handle(DataSourceCreatedNotification notification)
            {
                var thing = notification.State;
            }
        }
    
        public class DataSourceCreatingNotificationHandler : INotificationHandler<DataSourceCreatingNotification>
        {
            public void Handle(DataSourceCreatingNotification notification)
            {
                var thing = notification.State;
            }
        }
    
        public class DataSourceDeletedNotificationHandler : INotificationHandler<DataSourceDeletedNotification>
        {
            public void Handle(DataSourceDeletedNotification notification)
            {
                var thing = notification.State;
            }
        }
    
        public class DataSourceDeletingNotificationHandler : INotificationHandler<DataSourceDeletingNotification>
        {
            public void Handle(DataSourceDeletingNotification notification)
            {
                var thing = notification.State;
            }
        }
    
        public class DataSourceSavedNotificationHandler : INotificationHandler<DataSourceSavedNotification>
        {
            public void Handle(DataSourceSavedNotification notification)
            {
                var thing = notification.SavedEntities;
            }
        }
    }
    

    and...

    using My.Notifications;
    using Umbraco.Cms.Core.DependencyInjection;
    using Umbraco.Forms.Core.Services.Notifications;
    
    namespace My.Extensions
    {
        public static class UmbracoBuilderExtensions
        {
            public static IUmbracoBuilder AddNotificationHandlers(this IUmbracoBuilder builder)
            {
                builder.AddNotificationHandler<DataSourceSavingNotification, DataSourceSavingNotificationHandler>();
                builder.AddNotificationHandler<FolderCreatedNotification, FolderCreatedNotificationHandler>();
                builder.AddNotificationHandler<FolderCreatingNotification, FolderCreatingNotificationHandler>();
                builder.AddNotificationHandler<FolderDeletedNotification, FolderDeletedNotificationHandler>();
                builder.AddNotificationHandler<FolderDeletingNotification, FolderDeletingNotificationHandler>();
                builder.AddNotificationHandler<FolderSavedNotification, FolderSavedNotificationHandler>();
                builder.AddNotificationHandler<FolderSavingNotification, FolderSavingNotificationHandler>();
                builder.AddNotificationHandler<FormCreatedNotification, FormCreatedNotificationHandler>();
                builder.AddNotificationHandler<FormCreatingNotification, FormCreatingNotificationHandler>();
                builder.AddNotificationHandler<FormDeletedNotification, FormDeletedNotificationHandler>();
                builder.AddNotificationHandler<FormDeletingNotification, FormDeletingNotificationHandler>();
                builder.AddNotificationHandler<FormPrePopulateNotification, FormPrePopulateNotificationHandler>();
                builder.AddNotificationHandler<FormSavedNotification, FormSavedNotificationHandler>();
                builder.AddNotificationHandler<FormSavingNotification, FormSavingNotificationHandler>();
                builder.AddNotificationHandler<FormValidateNotification, FormValidateNotificationHandler>();
                builder.AddNotificationHandler<PrevalueSourceCreatedNotification, PrevalueSourceCreatedNotificationHandler>();
                builder.AddNotificationHandler<PrevalueSourceCreatingNotification, PrevalueSourceCreatingNotificationHandler>();
                builder.AddNotificationHandler<PrevalueSourceDeletedNotification, PrevalueSourceDeletedNotificationHandler>();
                builder.AddNotificationHandler<PrevalueSourceDeletingNotification, PrevalueSourceDeletingNotificationHandler>();
                builder.AddNotificationHandler<PrevalueSourceSavedNotification, PrevalueSourceSavedNotificationHandler>();
                builder.AddNotificationHandler<PrevalueSourceSavingNotification, PrevalueSourceSavingNotificationHandler>();
                builder.AddNotificationHandler<RecordApprovedNotification, RecordApprovedNotificationHandler>();
                builder.AddNotificationHandler<RecordCreatingNotification, RecordCreatingNotificationHandler>();
                builder.AddNotificationHandler<RecordDeletedNotification, RecordDeletedNotificationHandler>();
                builder.AddNotificationHandler<RecordDeletingNotification, RecordDeletingNotificationHandler>();
                builder.AddNotificationHandler<RecordFetchingNotification, RecordFetchingNotificationHandler>();
                builder.AddNotificationHandler<RecordSavingNotification, RecordSavingNotificationHandler>();
                builder.AddNotificationHandler<RecordStateChangeNotification, RecordStateChangeNotificationHandler>();
                builder.AddNotificationHandler<RecordSubmittedNotification, RecordSubmittedNotificationHandler>();
                builder.AddNotificationHandler<WorkflowCreatedNotification, WorkflowCreatedNotificationHandler>();
                builder.AddNotificationHandler<WorkflowCreatingNotification, WorkflowCreatingNotificationHandler>();
                builder.AddNotificationHandler<WorkflowDeletedNotification, WorkflowDeletedNotificationHandler>();
                builder.AddNotificationHandler<WorkflowDeletingNotification, WorkflowDeletingNotificationHandler>();
                builder.AddNotificationHandler<WorkflowExecutionCancelledNotification, WorkflowExecutionCancelledNotificationHandler>();
                builder.AddNotificationHandler<WorkflowExecutionCompletedNotification, WorkflowExecutionCompletedNotificationHandler>();
                builder.AddNotificationHandler<WorkflowExecutionFailedNotification, WorkflowExecutionFailedNotificationHandler>();
                builder.AddNotificationHandler<WorkflowExecutionNotConfiguredNotification, WorkflowExecutionNotConfiguredNotificationHandler>();
                builder.AddNotificationHandler<WorkflowExecutionStartedNotification, WorkflowExecutionStartedNotificationHandler>();
                builder.AddNotificationHandler<WorkflowSavedNotification, WorkflowSavedNotificationHandler>();
                builder.AddNotificationHandler<WorkflowSavingNotification, WorkflowSavingNotificationHandler>();
                builder.AddNotificationHandler<DataSourceCreatedNotification, DataSourceCreatedNotificationHandler>();
                builder.AddNotificationHandler<DataSourceCreatingNotification, DataSourceCreatingNotificationHandler>();
                builder.AddNotificationHandler<DataSourceDeletedNotification, DataSourceDeletedNotificationHandler>();
                builder.AddNotificationHandler<DataSourceDeletingNotification, DataSourceDeletingNotificationHandler>();
                builder.AddNotificationHandler<DataSourceSavedNotification, DataSourceSavedNotificationHandler>();
    
                return builder;
            }
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft