Query Form Responses as per sete in Multisite project

Posted by Community Admin on 04-Aug-2018 05:29

Query Form Responses as per sete in Multisite project

All Replies

Posted by Community Admin on 02-Dec-2014 00:00

Hi

I have a multisite project and wants fetch Form responses per site in a custom control, please help me what is the query to fetch records of form responses per site. Its too urgent, please help.

Also If possible send me the code how to bind all response records to a repeater control in my custom control. 

 

Posted by Community Admin on 04-Dec-2014 00:00

Hello Thomas,

Thank you for contacting us.

By default, when running Sitefinity in Multisite mode, the current site should be an abstraction when getting the items through the API, as we have this (filtering by the current site items) implemented out of the box.

When working with the API, by default the majority of our Managers have the implementation to return the items from the default provider of the current site. However, the case with FormsManager is a bit different, since forms do not have providers and thus when using the API you always get all the forms from all the sites and not only the forms from the current site.

To be able to achieve the desired functionality you will need to get the forms directly from the forms service using the following sample code:

var formService = new FormsService();
var formsFromCurrentSite = formService.GetFormDescriptions("", "", 0, 0, false);

This is the way we filter the forms in the Sitefinity backend for the different sites. The GetFormDescriptions() method of the FormsService.cs has internal logic and methods to get the forms from the current site when the last parameter is set to false. 

Please note to add the following using statement:
using Telerik.Sitefinity.Modules.Forms.Web.Services;

To work only with the entries of the forms you can run the query from our Documentation:

http://www.sitefinity.com/documentation/documentationarticles/querying-form-responses

You can filter the returned entries collection further by SourceSiteId. Something like this:

items = formsManager.GetFormEntries(entryType, filter, sortExpression, skip, take, ref totalCount).Cast<FormEntry>();
               if (siteId != Guid.Empty)
               
                   items = items.Where(item => item.SourceSiteId == siteId);
               

To be able to obtain a site's id I would suggest to take a look at the following Forum discussion. We have provided some useful Multisite API queries which you can utilize:

http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/multisite---accessing-content-across-sites-

I hope you find this informative and helpful and please let me know if you have any additional questions.

Regards,
Pavel Benov
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed