question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Cannot set Text Editor's content with frappe.new_doc()

See original GitHub issue

Assume I have a DocType Task with these fields:

  • subject (Data)
  • description (Text Editor)

If I call the following in JavaScript, the new Tasks subject will be set to “New task” but the description will be left blank.

frappe.new_doc("Task", {"description": "Do stuff", "subject": "New task"})

Same problem with frappe.route_options().

This happens with all fields of type Text Editor.

Though this works:

frm.doc.description = "Do stuff"
frm.refresh()

Version

Frappe Framework: v11.1.32 (master)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gwhitneycommented, Dec 15, 2020

Sure. I have some end-of-year deadlines for the organization I am setting up with ERPNext, so I likely won’t get to it until early in the new year, but would be happy to.

1reaction
gwhitneycommented, Nov 9, 2020

Some comments on the PR #11900 I just filed to address this: since it turns out not to be practical to simply allow any field to be specified by the route_options argument to frappe.new_doc – in particular, trying to set fields of type Table in this way goes haywire – I left the route_options alone, and instead enhanced the behavior of the init_callback argument, so that it is called regardless of whether the DocType has a Quick Entry form. So with #11900 in place, the OP can accomplish the original desired effect via:

frappe.new_doc("Task", {"subject": "New task"}, doc => {doc.description = "Do stuff";});

and (for example) I can create a new Journal Entry with the posting date set and an accounts line filled in via

frappe.new_doc("Journal Entry", {"voucher_type": "Bank Entry"}, doc => {
    doc.posting_date = me.data.date;
    let newacc = frappe.model.add_child(doc, "accounts");
    newacc.account = ba_doc.account;
    newacc.account_currency = me.data.currency;
    newacc.debit_in_account_currency = me.data.credit;
    newacc.credit_in_account_currency = me.data.debit;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring the Portable Text Editor - Sanity.io
How to configure the Portable Text Editor.
Read more >
The CMS Guide: 6 problems to overcome in your rich text editor
Learn about 6 most common CMS problems you can face while managing and editing web content and how the right rich text editor...
Read more >
Git - OpenForge
raise AttributeError() ... `site_config` is a set of site wide settings like database name, password, ... frappe.throw(_("Can not edit Read Only fields")).
Read more >
Editing rich text content | Xperience 13 Documentation - Kentico
You can edit the content in a WYSIWYG ("What You See Is What You Get") manner, which is an intuitive way to create...
Read more >
Build rich text editors in React using Draft.js and react-draft ...
Rich text editors enable you to control the appearance of the text and provide a powerful way for content creators to create and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found