Hi Tapasya,
Yes, direct SQL-driven field values from KX13 are not supported in XbyK — this is an intentional architectural change. The recommended approach is a custom form component, and it's actually cleaner and more maintainable than the old SQL query approach once set up.
How to implement it
Create a custom form component that populates a dropdown from your data source:
- Create a component class implementing
FormComponent<TProperties, TValue> with a DropDownListComponent base or your own select rendering
- In the component, inject the appropriate service or use
IInfoProvider<BizFormInfo> to query CMS_Form data — no raw SQL needed, use the Kentico object model
- Filter by current site using
SiteContext.CurrentSiteName or pass the site identifier via component properties
- Register the component with
[assembly: RegisterFormComponent] attribute
A minimal example for your use case:
[assembly: RegisterFormComponent(
FormSelectorComponent.IDENTIFIER,
typeof(FormSelectorComponent),
"Form selector")]
public class FormSelectorComponent : SelectorFormComponent<FormSelectorProperties>
{
protected override IEnumerable<HtmlOptionItem> GetHtmlOptions()
{
return BizFormInfo.Provider.Get()
.WhereEquals("FormSiteID", SiteContext.CurrentSiteID)
.Select(f => new HtmlOptionItem
{
Value = f.FormName,
Text = f.FormDisplayName
});
}
}
If you still need raw SQL
If the data source is outside the Kentico object model (a custom table or external DB), inject IConnectionStringService and use ConnectionHelper.ExecuteQuery inside the component. This is supported but keep it to cases where no typed provider exists.
Key points to remember
- Custom form components are reusable across all content types once registered
- The component renders in the admin UI automatically — no additional wiring needed
- For performance, consider caching the dropdown options if the source data changes infrequently, using
IProgressiveCache
This is the fully supported path in XbyK and gives you much more control than the old SQL query approach in KX13.
Hope that helps!