Bizforms without physical data in Kentico 10?

Nathalie Vallières asked on November 12, 2018 19:25

Hello,

I was wondering if it was possible to use the Bizforms without storing physical data (and just using the email notification).

Our client wants to keep the bizform to send email notifications to them/user, but remove any data from being stored physically as there are sensitive information they don't want to store.

Is there a way to do that in Kentico 10?

Is there a work-around that's optimal? Currently, we have a script that waits 25 seconds for the email notification to be sent before it's deleted, but it has flaws and will regularly not remove some data. Also, it's a cheap-ass workaround as the data will still be saved for that moment and sometimes not even be deleted. We have upgraded from Kentico 8 so I was wondering if there is a better solution for this now.

Thanks!

Recent Answers


Zach Perry answered on November 12, 2018 19:57 (last edited on November 12, 2018 19:58)

1: You can use an event to trigger the delete of the content instead of a script. The Email notification should be created at the same time as the the information is stored, so you could just tie into the InsertAfter event on the biz form and then delete it then.

1a: Tie into Events on Insert.Before and stop the information from being stored.

Handling Events BizForm Events

2: Create a custom web part that just send the form data right away. Form fields may be static unless you use an actual form, which is possible, but more complicated.

** Information in the BizForm is still stored in the Email Queue table, and may be stored even after sending depending on your settings.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on November 12, 2018 19:57 (last edited on November 12, 2018 20:03)

Essentially you want to prevent DB record creation. You can attach to biz form global event:

using CMS;
using CMS.DataEngine;
using CMS.DocumentEngine;

// Registers the custom module into the system
[assembly: RegisterModule(typeof(CustomInitializationModule))]

public class CustomInitializationModule : Module
{
    // Module class constructor, the system registers the module under the name "CustomInit"
    public CustomInitializationModule()
        : base("CustomInit")
    {
    }
    protected override void OnInit()
    {
        base.OnInit();

        // Assigns custom handlers to events
        BizFormItemEvents.Insert.Before += CancelFormDataInsert;
    }


    void CancelFormDataInsert(object sender, ObjectEventArgs e)
    {
            e.Cancel();
    }
}    

P.S. This code is not tested- it is just to give you an idea ;).

P.P.S. I just found the answer :)

1 votesVote for this answer Mark as a Correct answer

Nathalie Vallières answered on November 12, 2018 20:05

Humm, I might try the Before event and see if the email is still sent, it's worth a shot I think.

Currently, we were using BizFormItemEvents.Insert.After += FormItem_InsertAfterHandler; and deleting it after it was created, but for some reasons, it didn't work once in a while...

I'll try the Cancel event, which seems the easiest solution to implement and test. As long as the email is sent, I'm fine with it.

Unfortunately, the site is very big and they have 20+ forms managed in the Bizforms panel. It's not currently possible to implement a custom solution due to restrictive budget and time.

But I'll try the cancel approach. I'll come back with how it went.

0 votesVote for this answer Mark as a Correct answer

Zach Perry answered on November 12, 2018 20:11

If you are going to do the cancel, make sure you look at that link Peter has, it looks like the record has to be inserted for the notification to trigger, so you can send it manually in the insert before then cancel.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on November 12, 2018 20:56 (last edited on November 12, 2018 20:56)

Make sure that you are canceling it only for specific form not for all of them :)

void CancelFormDataInsert(object sender, ObjectEventArgs e)
{
     if (e.Item.ClassName == "yourform.classname")
     {
        e.Cancel();
     }
}
1 votesVote for this answer Mark as a Correct answer

Nathalie Vallières answered on November 12, 2018 21:40

Yeah, thanks for the clarification, I already knew about the ClassName check. I'll try both solutions when I get to work on this. Thanks for the answers.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.