Getting Values of Fields to Text Editor Field when saving

@bahaou

Yes I tried with that code. Its not working.

Yes, The letter should be well formatted. Everything is okay. Only the Currency values are issue.

@misltechnical you can change the format when printing .
actually why are you not using print format instead of this method ?

hi sir i have a similiar query

sir i have a similiar query, would you be able to help?

It has worked perfectly with me in a similar case!
Thank you Thank you Thank you!

I have just improved your code a little bit to make it reusable:

frappe.ui.form.on('F-Quotation', {
  terms_and_conditions_template: function (frm) {
    if (frm.doc.terms_and_conditions_template) {
      frappe.call({
        method: "frappe.client.get",
        args: {
          doctype: "Terms and Conditions",
          name: frm.doc.terms_and_conditions_template
        },
        callback(r) {
          if (r.message) {
            let terms = r.message.terms;

            // Define the replacements
            const replacements = {
              "{{letter_to}}": frm.doc.letter_to,
              "{{care_of}}": frm.doc.care_of,
              // Add more replacements as needed
            };

            // Perform the replacements
            for (const [key, value] of Object.entries(replacements)) {
              terms = terms.replace(new RegExp(key, 'g'), value);
            }

            frm.set_value("terms_and_conditions", terms);
          }
        }
      });
    } else {
      frm.set_value("terms_and_conditions", "");
    }
  }
});