Frappe Errors Clientscripts logo

Frappe Errors Clientscripts

Organization
Impertio-Studio
frappe-errors-clientscripts

Use when debugging or preventing errors in Frappe Client Scripts. Prevents TypeError, frappe.call failures, async/await mistakes, cur_frm vs frm confusion, field not found, child table access errors, timing issues, CSRF token errors, and permission denied on frappe.call. Covers error diagnosis flowchart and debug tools for v14/v15/v16. Keywords: client script error, TypeError, frappe.call, async await,, Cannot read properties of undefined, TypeError, browser console error, script not running, form not updating. cur_frm, field not found, child table, CSRF, permission denied.

Overview

PublisherImpertio-Studio
RepositoryFrappe_Claude_Skill_Package
Skill namefrappe-errors-clientscripts
Stars
180
Forks
53
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Impertio-Studio on GitHub. Read the source before you install it.

Installation

Install the Frappe Errors Clientscripts AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package.git /tmp/Frappe_Claude_Skill_Package
mkdir -p .claude/skills
cp -r /tmp/Frappe_Claude_Skill_Package/skills/source/errors/frappe-errors-clientscripts .claude/skills/frappe-errors-clientscripts
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Frappe Errors Clientscripts in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Frappe Errors Clientscripts on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Frappe Errors Clientscripts is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Client Script Errors — Diagnosis and Resolution

Cross-refs: frappe-syntax-clientscripts (syntax), frappe-impl-clientscripts (workflows), frappe-errors-serverscripts (server-side).


Error Diagnosis Flowchart

ERROR IN CLIENT SCRIPT
├─► TypeError: Cannot read properties of undefined
│   ├─► "frm.doc.fieldname" → Field does not exist on DocType
│   ├─► "r.message.value" → Server returned null/error
│   └─► "row.fieldname" in child table → Row not fetched correctly
├─► frappe.call fails silently
│   ├─► Missing error callback → Add error handler
│   ├─► 403 Forbidden → Method not whitelisted (@frappe.whitelist)
│   ├─► 417 Expectation Failed → Server-side frappe.throw()
│   └─► 401 Unauthorized → Session expired or CSRF token invalid
├─► Uncaught (in promise) → Missing try/catch on async frappe.call
├─► Field appears blank after set_value → Timing issue (setup vs refresh)
├─► cur_frm is undefined → Using cur_frm in list/report context
└─► frappe.throw() does not prevent save → Used outside validate event

Error Message → Cause → Fix Table

Error MessageCauseFix
TypeError: Cannot read properties of undefined (reading 'fieldname')Field does not exist on DocType or doc not loadedALWAYS check frm.doc exists before accessing fields
TypeError: frm.set_value is not a functionUsing cur_frm shortcut that is undefinedALWAYS use the frm parameter from event handler
Uncaught (in promise)Unhandled async rejection from frappe.callALWAYS wrap async calls in try/catch
CSRFTokenError / 403 with CSRFToken mismatch after session timeoutALWAYS use frappe.call() (handles CSRF automatically)
Not permitted / 403 on frappe.callServer method missing @frappe.whitelist()ALWAYS add @frappe.whitelist() decorator to API methods
frappe.throw() not preventing savefrappe.throw() used outside validate eventALWAYS use frappe.throw() only in validate
field not found: xyz in set_queryFieldname typo or field not in child tableVerify exact fieldname against DocType definition
row.item_code is undefinedAccessing child row wrong — locals not syncedUse frappe.get_doc(cdt, cdn) in child table events
frm.set_value not workingCalled in setup before form fully loadedMove field-setting logic to refresh event
Maximum call stack exceededCircular trigger — field change fires own handlerUse frm.flags guard to break recursion

Critical Error Patterns

1. cur_frm vs frm: The #1 Beginner Mistake

javascript
// ❌ WRONG — cur_frm is undefined in many contexts
frappe.ui.form.on('Sales Order', {
    customer(frm) {
        cur_frm.set_value('territory', 'Default');  // BREAKS in list view
    }
});

// ✅ CORRECT — ALWAYS use the frm parameter
frappe.ui.form.on('Sales Order', {
    customer(frm) {
        frm.set_value('territory', 'Default');
    }
});

Rule: NEVER use cur_frm. ALWAYS use the frm parameter passed to every event handler.

2. Async/Await: Silent Failure Without try/catch

javascript
// ❌ WRONG — Unhandled rejection crashes silently
frappe.ui.form.on('Sales Order', {
    async customer(frm) {
        let r = await frappe.call({
            method: 'myapp.api.get_data',
            args: { customer: frm.doc.customer }
        });
        frm.set_value('credit_limit', r.message.limit);  // r.message may be null
    }
});

// ✅ CORRECT — try/catch with null check
frappe.ui.form.on('Sales Order', {
    async customer(frm) {
        if (!frm.doc.customer) return;
        try {
            let r = await frappe.call({
                method: 'myapp.api.get_data',
                args: { customer: frm.doc.customer }
            });
            if (r.message) {
                frm.set_value('credit_limit', r.message.limit || 0);
            }
        } catch (error) {
            console.error('Customer fetch failed:', error);
            frappe.show_alert({
                message: __('Could not load customer details'),
                indicator: 'red'
            }, 5);
        }
    }
});

3. Child Table Access: Wrong Pattern

javascript
// ❌ WRONG — frm.doc.items[0] may not reflect latest state
frappe.ui.form.on('Sales Order Item', {
    item_code(frm, cdt, cdn) {
        let row = frm.doc.items.find(r => r.name === cdn);  // fragile
        row.rate = 100;  // Does not trigger UI refresh
    }
});

// ✅ CORRECT — Use frappe.get_doc and frappe.model.set_value
frappe.ui.form.on('Sales Order Item', {
    item_code(frm, cdt, cdn) {
        let row = frappe.get_doc(cdt, cdn);
        if (!row.item_code) return;
        frappe.model.set_value(cdt, cdn, 'rate', 100);  // Triggers refresh
    }
});

4. Timing: setup vs refresh

javascript
// ❌ WRONG — set_value in setup, form not ready
frappe.ui.form.on('Sales Order', {
    setup(frm) {
        frm.set_value('company', 'My Company');  // May not work
    }
});

// ✅ CORRECT — set_query in setup, set_value in refresh/onload
frappe.ui.form.on('Sales Order', {
    setup(frm) {
        // Filters belong in setup
        frm.set_query('customer', () => ({ filters: { disabled: 0 } }));
    },
    refresh(frm) {
        // Value changes belong in refresh (or onload for new docs)
        if (frm.is_new()) {
            frm.set_value('company', 'My Company');
        }
    }
});

5. frappe.throw() Scope: Only Works in validate

javascript
// ❌ WRONG — throw in customer change does NOT prevent save
frappe.ui.form.on('Sales Order', {
    customer(frm) {
        if (!frm.doc.customer) {
            frappe.throw(__('Customer required'));  // Stops script, NOT save
        }
    }
});

// ✅ CORRECT — throw in validate prevents save
frappe.ui.form.on('Sales Order', {
    customer(frm) {
        if (!frm.doc.customer) {
            frappe.msgprint({ message: __('Customer required'), indicator: 'orange' });
        }
    },
    validate(frm) {
        if (!frm.doc.customer) {
            frappe.throw(__('Customer is required'));  // Prevents save
        }
    }
});

6. Recursion Guard with Flags

javascript
// ❌ WRONG — discount change triggers amount recalc, which triggers discount...
frappe.ui.form.on('Sales Order', {
    discount_percent(frm) {
        frm.set_value('grand_total', calculate(frm));  // Fires on_change loop
    }
});

// ✅ CORRECT — Use flags to break the cycle
frappe.ui.form.on('Sales Order', {
    discount_percent(frm) {
        if (frm.flags.skip_recalc) return;
        frm.flags.skip_recalc = true;
        frm.set_value('grand_total', calculate(frm));
        frm.flags.skip_recalc = false;
    }
});

Debug Tools

ToolHow to UseWhen
Browser Console (F12)console.log(frm.doc)Inspect form state
console.table()console.table(frm.doc.items)View child table rows
JSON.parse(JSON.stringify(frm.doc))Deep-clone for snapshotAvoid circular refs in console
frappe.boot.developer_modeCheck if dev mode onConditional debug logging
frappe.ui.toolbar.clear_cache()Clear client cacheAfter deploying script changes
Network tab (F12)Filter XHR requestsInspect frappe.call payloads
frappe.show_alert({message: 'debug', indicator: 'blue'}, 5)Visual debug in UIQuick feedback without console

ALWAYS / NEVER Rules

ALWAYS

  1. Use the frm parameter — NEVER use cur_frm [v14+]
  2. Wrap async frappe.call in try/catch — Unhandled rejections fail silently
  3. Use __() for all user-facing strings — Required for translation
  4. Collect multiple validation errors before calling frappe.throw()
  5. Use frappe.get_doc(cdt, cdn) to access child table rows in events
  6. Put frappe.throw() only in validate to prevent save
  7. Check r.message for null before accessing server response properties
  8. Use frappe.model.set_value(cdt, cdn, field, value) in child table events

NEVER

  1. NEVER use alert(), confirm(), or prompt() — Use frappe.msgprint / frappe.confirm
  2. NEVER expose stack traces to users — Log to console, show friendly message
  3. NEVER use cur_frm — It is unreliable and undefined in many contexts
  4. NEVER leave console.log in production — Use conditional frappe.boot.developer_mode check
  5. NEVER mix .then() and await in the same function — Pick one pattern
  6. NEVER call frm.set_value in setup — Form is not ready; use refresh or onload
  7. NEVER ignore the error callback on frappe.call when using callback style

Reference Files

FileContents
references/examples.mdReal error scenarios with diagnosis
references/anti-patterns.mdCommon mistakes with before/after fixes
references/patterns.mdDefensive error handling patterns

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Frappe Errors Clientscripts AI skill do?

Use when debugging or preventing errors in Frappe Client Scripts. Prevents TypeError, frappe.call failures, async/await mistakes, cur_frm vs frm confusion, field not found, child table access errors, timing issues, CSRF token errors, and permission denied on frappe.call. Covers error diagnosis flowchart and debug tools for v14/v15/v16. Keywords: client script error, TypeError, frappe.call, async await,, Cannot read properties of undefined, TypeError, browser console error, script not running, form not updating. cur_frm, field not found, child table, CSRF, permission denied.

Why use Frappe Errors Clientscripts on TypingMind?

Because you install it once and use it with any model. Frappe Errors Clientscripts is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Frappe Errors Clientscripts in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package/tree/main/skills/source/errors/frappe-errors-clientscripts. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Frappe Errors Clientscripts?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Frappe Errors Clientscripts?

As many as you like. As long as a model supports skills, you can use Frappe Errors Clientscripts with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Frappe Errors Clientscripts AI skill free?

Yes. It is published on GitHub by Impertio-Studio under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇