search_expense_reports
Find and filter expense reports in Autotask by submitter, status, or page size to manage financial documentation and track reimbursement processes.
Instructions
Search for expense reports with optional filters
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| submitterId | No | Filter by submitter resource ID | |
| status | No | Filter by status (1=New, 2=Submitted, 3=Approved, 4=Paid, 5=Rejected, 6=InReview) | |
| pageSize | No | Number of results to return (default: 25, max: 100) |
Implementation Reference
- src/handlers/tool.handler.ts:746-768 (schema)Tool schema definition including name, description, and input schema validation for search_expense_reportsname: 'search_expense_reports', description: 'Search for expense reports with optional filters', inputSchema: { type: 'object', properties: { submitterId: { type: 'number', description: 'Filter by submitter resource ID' }, status: { type: 'number', description: 'Filter by status (1=New, 2=Submitted, 3=Approved, 4=Paid, 5=Rejected, 6=InReview)' }, pageSize: { type: 'number', description: 'Number of results to return (default: 25, max: 100)', minimum: 1, maximum: 100 } }, required: [] } },
- src/handlers/tool.handler.ts:1251-1258 (handler)Dispatch handler in callTool method that maps arguments and calls the AutotaskService.searchExpenseReports methodcase 'search_expense_reports': result = await this.autotaskService.searchExpenseReports({ submitterId: args.submitterId, status: args.status, pageSize: args.pageSize }); message = `Found ${result.length} expense reports`; break;
- Core implementation of searchExpenseReports: builds filters for submitterId and status, calls autotask-node client.expenses.list API, and returns expense reportsasync searchExpenseReports(options: AutotaskQueryOptionsExtended = {}): Promise<AutotaskExpenseReport[]> { const client = await this.ensureClient(); try { this.logger.debug('Searching expense reports with options:', options); // Build filter based on provided options const filters = []; if (options.submitterId) { filters.push({ field: 'resourceId', op: 'eq', value: options.submitterId }); } if (options.status) { filters.push({ field: 'status', op: 'eq', value: options.status }); } const queryOptions = { filter: filters.length > 0 ? filters : [{ field: 'id', op: 'gte', value: 0 }], pageSize: options.pageSize || 25 }; const result = await client.expenses.list(queryOptions); const reports = (result.data as any[]) || []; this.logger.info(`Retrieved ${reports.length} expense reports`); return reports as AutotaskExpenseReport[]; } catch (error) { this.logger.error('Failed to search expense reports:', error); throw error; } }