Frappe Frontend Development
You are invoking the specialized Frappe frontend agent for client-side JavaScript development.
Request
$ARGUMENTS
Agent Invocation
Use the Task tool to spawn the frappe-fullstack:frappe-frontend agent with the following configuration:
IMPORTANT: The agent name MUST be fully qualified: frappe-fullstack:frappe-frontend
Agent Prompt Template
You are working on a Frappe/ERPNext frontend task.
## Task
{user's task description}
## Context
- Working directory: {current directory}
- This is client-side JavaScript for Frappe Desk
## Your Responsibilities
1. **Analyze the Request**
- Understand what UI/UX functionality is needed
- Identify which DocTypes and forms are involved
- Determine if this is form script, dialog, or list customization
2. **Explore the Codebase**
- Find existing client scripts for patterns
- Check for reusable dialog patterns
- Identify existing UI conventions
3. **Implement the Solution**
- Write clean, well-documented JavaScript
- Follow Frappe client-side conventions
- Handle async operations properly
- Include proper error handling and user feedback
4. **Provide Complete Code**
- Form event handlers (refresh, validate, field changes)
- Custom buttons and actions
- Dialogs and prompts
- frappe.call for server communication
## Output Requirements
- Provide complete, working JavaScript code
- Include file paths (doctype.js location)
- Explain any server-side APIs needed
- Note if bench build is requiredCapabilities
The frappe-frontend agent excels at:
Form Scripts
frappe.ui.form.on('My DocType', {
refresh: function(frm) {
// Add buttons, toggle fields
},
validate: function(frm) {
// Client-side validation
},
field_name: function(frm) {
// Field change handler
}
});Child Table Events
frappe.ui.form.on('My DocType Item', {
qty: function(frm, cdt, cdn) {
let row = locals[cdt][cdn];
row.amount = row.qty * row.rate;
frm.refresh_field('items');
}
});Custom Buttons
frm.add_custom_button(__('Action'), function() {
// Button logic
}, __('Actions'));Dialogs
let dialog = new frappe.ui.Dialog({
title: __('My Dialog'),
fields: [
{fieldname: 'field1', fieldtype: 'Data', label: 'Field 1'}
],
primary_action: function(values) {
// Handle submission
}
});
dialog.show();Server Calls
frappe.call({
method: 'myapp.api.my_function',
args: { param: value },
freeze: true,
callback: function(r) {
// Handle response
}
});Field Manipulation
// Show/hide
frm.toggle_display('fieldname', condition);
// Required
frm.toggle_reqd('fieldname', condition);
// Read-only
frm.set_df_property('fieldname', 'read_only', 1);
// Set query for Link field
frm.set_query('customer', function() {
return { filters: { status: 'Active' } };
});Common Tasks
"Add button to create follow-up task" → Custom button with dialog for task details
"Show/hide fields based on document type selection" → Field change handler with toggle_display
"Auto-calculate totals when qty or rate changes" → Child table field events
"Validate that end date is after start date" → validate event with frappe.throw
"Fetch customer details when customer is selected" → Field change with frappe.call
"Add custom filter to link field" → set_query with dynamic filters
Tools Available to Agent
- Glob: Find JavaScript files
- Grep: Search for existing patterns
- Read: Read existing client scripts
- Write: Create new files
- Edit: Modify existing code
- Bash: Check file structure, run bench build
File Locations
my_app/
└── my_module/
└── doctype/
└── my_doctype/
└── my_doctype.js # Form scriptFor list view:
my_app/
└── my_module/
└── doctype/
└── my_doctype/
└── my_doctype_list.js # List scriptPost-Implementation
After the agent completes:
Build Assets (if new files created)
bashbench build --app my_appClear Cache
bashbench --site <site> clear-cacheHard Refresh Browser
- Ctrl+Shift+R to reload without cache
Check Browser Console
- F12 → Console for JavaScript errors