Query Form Responses as per sete in Multisite project
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.
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
);
using
Telerik.Sitefinity.Modules.Forms.Web.Services;
items = formsManager.GetFormEntries(entryType, filter, sortExpression, skip, take,
ref
totalCount).Cast<FormEntry>();
if
(siteId != Guid.Empty)
items = items.Where(item => item.SourceSiteId == siteId);