I made a custom widget that executes a query and then sends the response to this method in widget.tsx:
const populateDataSource = async (features: any[]) => {
const dataSourceManager = DataSourceManager.getInstance();
const outputDsId = `${props.id}-output`;
// Extract fields dynamically from features
const feature = features[0];
const attributes = feature.attributes;
const fields = Object.keys(attributes).reduce((acc, fieldName) => {
acc[fieldName] = {
name: fieldName,
alias: fieldName,
type: typeof attributes[fieldName] === 'number' ? 'esriFieldTypeDouble' :