Try our conversational search powered by Generative AI!

Selecting default data source of a form



I have a custom form container that is inherited from FormContainerBlock. How do I set its default data source to an existing implementation of IExternalSystem? I want every instance of this form container should have the default data source. 

Mar 11, 2019 11:51

Hi Hüseyin

You should be able to set the value of Forms_ConnectedDataSource on all FormContainerBlock types in the ContentCreating event in an Episerver Intialisation module. 


Mar 11, 2019 12:20

Hello David,

Thanks for your answer. It is possible to get the form container during an initialisation script by casting e.Content to the form container. However, the form block does not contain any property for ConnectedDataSource. Am I looking at the wrong place?

private void OnCreatingContent(object sender, ContentEventArgs e)
    if (!(e.Content is CustomFormContainer customFormContainer)) return;
    sbgFormContainer. //The object does not expose ConnectedDataSource
Mar 11, 2019 12:52

Hi Hüseyin

Its not exposed as a strongly typed property but you should be able to access it using the property collection. Something like:

((CustomFormContainer)sbgFormContainer).Property["Forms_ConnectedDataSource"] = <<your value here>>


Mar 11, 2019 12:55

Hi, thanks for the tip!

I see, the property accepts a PropertyConnectedDataSourceCollection object. Is it okay to initiate this only using the ID value? Otherwise, how can I create this object? One alternative can be to hold an instance where I copy the properties from, are there any other ways. 

Mar 11, 2019 13:15

The collection extends PropertyLongString so you could look at the string value on a configured form and set that in your init module

Mar 11, 2019 13:52

Hi, unfortunately this did not make any effect.

Mar 14, 2019 13:50
* 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.