Editing forms after submission

 

Hello All ,

How I can manipulate data of a form which is submitted.

I can read it , but not modify it.

Any kind of input is appreciated.

#194551 Jun 25, 2018 13:02
  • This message was deleted by Quan Tran at Jun 26, 2018 8:15.
  •  

    If you want to format/modify data before saving into Database you can hook into Forms' Submitting Event.

    Take a look at Forms Event Listener Demo

    
    
    
                                            
    #194586 Edited, Jun 26, 2018 8:26
  •  

    Hei Quan ,

    I need to modify the data after being submitted .

    I tried using Submitted event but it didn't worked.

    #194587 Jun 26, 2018 8:35
  •  

    Hi Himshikhar,

    You can use Submitted Event with method below to modify submission data

    		public void ModifySubmissionData(FormsSubmittedEventArgs args)
    		{
    			// get form container block
    			var formContainerBlock = args.FormsContent as FormContainerBlock;
    			var formLocale = formContainerBlock as ILocale;
    
    			// get form identity
    			var formIdentity = new FormIdentity { Guid = formContainerBlock.Form.FormGuid, Language = formLocale.Language.Name };
    
    			var _submissionStorageFactoryy = ServiceLocator.Current.GetInstance<SubmissionStorageFactory>();
    			// get submission storage base on form instance's configuration
    			var submissionStorage = _submissionStorageFactoryy.GetStorage(formIdentity);
    
    			submissionStorage.UpdateToStorage(args.FormSubmissionId, formIdentity, args.SubmissionData);
    		}



    #194589 Edited, Jun 26, 2018 9:19
  •  

    Thanks for the reply.

    I will explian you the scenario.

    1. First we use the event to submit the page and modilfy before submitting.
    2. Then we go to a payment gateway , this gateway is redirected from a controller.
    3. Payment page returns to same controller.
    4. Based on response from payment gateway , i need to update the Form submitted data from the controller.

    I hope it helps to understand my problem.

    #194590 Jun 26, 2018 10:08
  •  

    Hi Himshikhar,

    I think that whatever the business is, in order to update submission data stored in the database, we need to know FormIdentity and which FormSubmissionId were are going to update.

    As the code above shows that we use UpdateToStorage method to update submission data. You have to keep track both FormIdentity  and FormSubmissionId  when redirecting between pages/controllers

    #194595 Jun 26, 2018 10:46
  •  

    Thanks Quan , it worked just fine. :)

    #194602 Jun 26, 2018 11:30
  •  

    You're welcome... laughing

    #194635 Jun 27, 2018 6:40