Data Fetching
Why This Pattern?
const [loading, setLoading] = useState(false);
const [data, setData] = useState([]);
const [error, setError] = useState(null);
// ... manual API callsconst { loading, data, error } = useExecuteRequest(LocationServices.getAll());Service Configurations
// src/services.ts
import { ExecuteServiceConfig } from 'uxp/components';
export const LocationServices = {
getAll: (params = {}): ExecuteServiceConfig => ({
type: 'service',
app: 'Location',
service: 'Location:GetAllLocations',
parameters: params,
options: { json: true },
defaultValue: []
})
};
export const LocationTypeServices = {
getAll: (): ExecuteServiceConfig => ({
type: 'service',
app: 'Location',
service: 'LocationType:All',
parameters: {
__sort__: 'SortOrderValue',
__sortorder__: 'asc'
},
options: { json: true },
defaultValue: []
}),
create: (locationType: string): ExecuteServiceConfig => ({
type: 'service',
app: 'Location',
service: 'LocationType:Create',
parameters: { LocationType: locationType },
options: { json: true }
}),
update: (locationType: LocationType): ExecuteServiceConfig => ({
type: 'service',
app: 'Location',
service: 'LocationType:Update',
parameters: {
LocationTypeKey: locationType.LocationTypeKey,
LocationType: locationType.LocationType
},
options: { json: true }
}),
delete: (locationType: LocationType): ExecuteServiceConfig => ({
type: 'service',
app: 'Location',
service: 'LocationType:DeleteEx',
parameters: {
LocationTypeKey: locationType.LocationTypeKey
},
options: {}
})
};Config Types
Type
Use For
Key Options
Three Ways to Execute
1. useExecuteRequest Hook
2. executeConfig Function
3. useExecuteRequestCallback Hook
Quick Reference
Tool
State Updates
Use Case
Complete Example
Filter Patterns for ObjectSearchComponent
Understanding Filter Structure
Complete Filter Pattern
Paginated Select Fields
Cascading Dropdowns
Date Field Conversion
Common Mistakes
❌ WRONG
✅ CORRECT
Next Steps
Last updated