Pulling Form Responses Forward through a custom Form Widget

Matthew Hudock asked on November 16, 2022 16:27

Hi All,

We have come across a use case that we need to be able to dynamically select a form within Kentico and after selecting said form have the widget pull the column names from the form, as well as the attached responses to said columns/responses has anyone had success doing this? The only documentation I could find online was pulling a hardcoded form response and not a dynamic one. Any guidance here would be greatly appreciated.

I should note that I was able to get the form selector part working, I'm just having issues pulling the column names/data.

TIA!

Recent Answers


Juraj Ondrus answered on November 17, 2022 05:28 (last edited on November 17, 2022 05:30)

If you want to get the form field definition, you need to use DataClassInfoProvider.GetDataClassInfo(formClassName) to get the class information - then in the dataclass info object you should have the form fields definitions available and once you have this object, you can also access the data, for example:

 ObjectQuery< BizFormItem > data = BizFormItemProvider.GetItems(formClassName);

// Loops through the form s data records
foreach (BizFormItem item in data)
{
    // Gets the values of the 'UserEmail' and 'UserMessage' text fields for the given data record
    string test = item.GetStringValue("FieldName", "");   

And/Or you can also take a look on the FormProvider methods.

1 votesVote for this answer Mark as a Correct answer

Matthew Hudock answered on November 21, 2022 15:37

Hi Juraj,

Thank you for the response. I did try to implement the above however i'm still having issues pulling forward the data to a view from the data field, any suggestions on how to do that? Would it be similar to passing through a View Model file? Is a View Model file even necessary for this?

Thank you!

0 votesVote for this answer Mark as a Correct answer

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