Apply "in_words" function with Client Scripts

Hello everyone,
I add “in_words” field in Payment Request doctype. I use client script to call money_to_words function in utils of frappe but it doesn’t work.

I use form option and this is my js code:

frappe.ui.form.on('Payment Request', {
     onload: function (frm) {{
            method: "",
            args: {
                "number": frm.doc.grand_total, 
                "main_currency": "VND"
            callback: function (inWords) {
                if (inWords){
                    frm.set_value("in_words", inWords.message);

What wrong with my code ??

Hi @Th_Nguy_n_Phu,

I think, It seems that the function is not whitelisted.

Whitelisting is a security feature that restricts access to server-side functions. You need to whitelist the function before you can use it in your client-side scripts.

Thank You!

1 Like

Thanks for your suggession.

I modified a new “money_in_words” function in server-scripts for Payment Request doctype.

I have some stucks:

  • how to get information of current payment request ?
  • path of this function to pass method argument ?

You have any idea.


Hi @Th_Nguy_n_Phu,


if doc.grand_total:
    doc.in_words = frappe.utils.money_in_words(doc.grand_total, "VND")

I hope this helps.
Thank You!

Oh thanks for your code and apologize for replying lately.

I want to pass Payment Request ID automation, in my code is “docid”.


We just share the syntax.
Please set your code according to.

what is docid?
when you print then show none.

So first define the docid and then apply your scenario.

Thank You!

After I had researched in community, I knew that: only use script API in server scripts (can’t use “import” syntax and “doc” is representative for “cur_frm” → right ?)

Finally, I try this code but it is’t working

inWords = frappe.utils.money_in_words(doc.grand_total, "VND")
frappe.db.set_value("Payment Request",, "in_words", inWords)

This is my setting.

Ps: I deployed by docker and added server_script_enabled config in server


# Get the document to be updated
doc = frappe.get_doc("Doctype Name", "Document Name")

# Update the field value
frappe.db.set_value("Doctype Name", "Document Name", "field_name", "new_value")

# Save the document

More details for check it.

Thanks You!

1 Like

Thanks for your reply

doc = frappe.get_doc("Doctype Name", "Document Name")
frappe.db.set_value("Doctype Name", "Document Name", "field_name", "new_value")

Both of them are passed by specific detail “Documet Name” argument, but I want to pass it automatically and update multiple records into database.
You have any solution


If you did not add the add this and check it.