Try our conversational search powered by Generative AI!

find all Episerver form



Is there any way to retrieve the all Episerver forms that created in all sites ?

I've found this one but didn't work:

Sep 09, 2022 5:31

what didn't work? did you get any FormsInfo to start with

Sep 09, 2022 8:29

Yes, I got the form info. but it is only returning 2 entries which I have plenty of forms.

I think it maybe doesn't search through the all pages

Index already updated 

Sep 09, 2022 8:31

Hi Vahid, does it have to be programatically? or can you do it through the database?

Sep 09, 2022 10:05


A bit late to the party, but I encountered a similar issue while attempting to retrieve all instances of FormContainerBlock. Initially, I used the following code to obtain form instances:

var formsInfoCollection = _formRepository.GetFormsInfo(null);

This approach effectively fetched forms located under the 'forms' root folder, aligning with expected behavior. However, it didn't return all form instances located under the 'blocks' root folder or those created 'for this page'— which is where a significant number of form instances were situated for me.

In search of an alternative that could access forms from the 'blocks' root and for this page, I explored various methods within formRepository to no avail. My exploration led me to experiment with ContentModelUsage, which ultimately seemed to return the results I expected. For those facing similar challenges, this approach might offer a solution.

var formContainerBlocks = GetAllFormContainerBlocks();

private IEnumerable<FormContainerBlock> GetAllFormContainerBlocks()
    var references = FindAllFormContainerBlocks();
    var formContainerBlocks = new List<FormContainerBlock>();

    foreach (var reference in references)
        if (_contentRepository.TryGet(reference, out FormContainerBlock formContainerBlock))

    return formContainerBlocks;

public IEnumerable<ContentReference> FindAllFormContainerBlocks()
	var contentType = _contentTypeRepository.Load<FormContainerBlock>();
	var usages = _contentModelUsage.ListContentOfContentType(contentType)
		.Select(x => x.ContentLink.ToReferenceWithoutVersion())
	return usages;

I decided to share my experience here, as I stumbled upon this thread while searching for solutions to my issue.


Edited, Feb 16, 2024 14:29

There is an extension method in EPiServer.Forms.UI for the IContentTypeRepository that does all of this for you:

var forms = _contentTypeRepository.GetExistingForms();

If you decompile the code it does basically the same things ... the following is the decompiled code.

    public static IEnumerable<FormInfo> GetExistingForms(this IContentTypeRepository contentTypeRepository)
        IEnumerable<ContentType> enumerable = from item in contentTypeRepository.List()
                                              where typeof(FormContainerBlock).IsAssignableFrom(item.ModelType)
                                              select item;
        List<FormInfo> list = new List<FormInfo>();
        IContentModelUsage instance = ServiceProviderExtensions.GetInstance<IContentModelUsage>(ServiceLocator.Current);
        IPermanentLinkMapper permanentLinkMapper = ServiceProviderExtensions.GetInstance<IPermanentLinkMapper>(ServiceLocator.Current);
        foreach (ContentType item in enumerable)
            IList<ContentUsage> list2 = instance.ListContentOfContentType(item);
            if (list2 != null && list2.Any())
                list.AddRange(list2.Select((ContentUsage x) => new FormInfo
                    FormGuid = permanentLinkMapper.Find(x.ContentLink).Guid,
                    Id = x.ContentLink.ID,
                    Name = x.Name

        return list;
Feb 20, 2024 16:28
Vincent - Feb 21, 2024 2:35
Thanks Mark. Good to know there is an existing method does the job though it's a bit weird to have this under ContentTypeRepoistory.
Mark Stott - Feb 21, 2024 14:30
It would make sense to put this in a IFormsRepository rather than making it an extension method of IContentTypeRepository. I literally stumbled on this because I was following a similar route to find all Form Container Blocks and then find and cleanse all form submissions associated with each instance of a form container block.
Quan Mai - Feb 21, 2024 14:39
I do think putting a List all method into a repository class is a bad idea - it's very easily misused, if not abused.

Hey Mark, 

Thank you for the information. I suspected there would be a mechanism to accomplish this, I just couldn't find it 🙃!

To elaborate further on my implementation, I have a custom form container that extends the default FormContainerBlock . For example,

public class MyCustomFormContainerBlock : FormContainerBlock
    // Custom implementation details

During the development, I observed that the code snippet below exclusively retrieves forms matching the exact type specified. I was expecting inheritance to play a part but it didn't. I also called Load() passing in the IFormContainerBlock interface but that caused a null exception.

var contentType = _contentTypeRepository.Load<FormContainerBlock>();

I later stumbled upon which mentions inheritance and offers solutions to this. However, I needed this for a one-off task so just created two lists for each type and merged them. Not ideal, especially if you have lots of extended forms but got the job done. Is there where you tell me there is something to help me here too :) ?

I'll take a look at the GetExistingForms() method you shared.


Edited, Feb 20, 2024 16:47
Mark Stott - Feb 20, 2024 16:53
The decompiled method code suggests it will handle the fact you have a custom FormContainerBlock. The opening statement is to get ALL content types from the IContentTypeRepository and then filters them to those which have a model that is assignable to the default FormContainerBlock. Definitely worth a try in your solution :)
Paul Griffiths - Feb 20, 2024 16:56
Even better! This is really good to know! Based on the code you shared it should solve the issue I experienced! I'll give it a try.

Thank you for sharing the information :)
Mark Stott - Feb 20, 2024 17:12
You’re welcome. Let me know how it works out for you :)

The database is your friend...

SELECT c.pkID, cl.Name
FROM tblContent c, tblContentLanguage cl
WHERE c.pkId = cl.fkContentID AND c.fkContentTypeId IN (SELECT pkId FROM tblContentType WHERE Name = 'FormContainerBlock')
Feb 21, 2024 17:30
* 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.