SaaS CMS has officially launched! Learn more now.

Updating a form submission in a controller



I have an existing Optimizely CMS 11 website where I have a custom form container that needs to be integrated with an external signing service. The form needs to redirect to the signing service after either the form is filled or after a formstep.

My first thought was to have the form on one page and when it gets submitted change the "SYSTEMCOLUMN_FinalizedSubmission" in the formssubmitting event to false, reopen the form on another page using the FormGuid, FormSubmissionId etc. From there let the user sign the form and then update the "SYSTEMCOLUMN_FinalizedSubmission" in the controller of the signing page. However, I haven't been able to figure out how to update the submitted data in a controller without directly quering the database. Another possible solution might be to call on a form event to update the data but I haven't had any luck finding out how to call on a formevent in a controller (if it even is possible).

Another possible solution that I've fiddled with is to use a formstep to redirect to the signing page and from there redirect back to the form in the next formstep. If it's not possible to change submitted formsdata I might need to go this route.

I've tried combing through the forums and haven't been able to find anything useful. Has anyone else attempted anything similar? Any advice is much appreciated

Edited, May 30, 2024 7:41

We did this with Swedish BankID but added it as an integrated formblock. 

If the BankID formblock was present in the form the submit button was disabled until the BID authentication had been performed.

Which external signing service will you use? Is there any API:s?

May 31, 2024 10:25
Oscar - Jun 03, 2024 14:00
Coincidentally this is also an integration to BankId.
Did you handle the authentication with JavaScript or in a validator for custom form element? I can't find anything on integrated formblock so I'm assuming you mean formelement.

If you're looking to update form data without resorting to direct database access, you can do this by getting the appropriate instance of IPermanentStorage and calling the UpdateToStorage method. Here's an example though, for simplicity, I've hard-coded the form ID and the submission ID, and I've used ServiceLocator:

//First get the storage provider for the form in question
var storageFactory = ServiceLocator.Current.GetInstance<SubmissionStorageFactory>();
var formId = new FormIdentity(Guid.Parse("b100041d-15a3-49a3-b107-f3443460b5b8"), "en"); // <- shouldn't be hard-coded
var formStorage = storageFactory.GetStorage(formId);
//I've hard-coded this but you'll probably want to fetch it dynamically e.g. from the querystring
var submissionId = "6BDE1012-43BC-42DF-ABFA-0195E06612D2";

//Create a submission object with the data fields we want to update
var submission = new Submission { Data = new PropertyBag(), Id = submissionId };
submission.Data["SYSTEMCOLUMN_FinalizedSubmission"] = true;

//Persist our changes
var returnedSubmissionId = formStorage.UpdateToStorage(Guid.Parse(submissionId), formId, submission);
May 31, 2024 11:59
Oscar - Jun 03, 2024 13:49
This worked perfectly, thank you!
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.