Custom field value is not shown in Print, Fullpage, PDF

I create one custom field called mydata in sales invoice form.

I create custom script for sales invoice. In that I set an value for mydata.

    frappe.ui.form.on("Sales Invoice", "onload_post_render", function(frm) {
        var data = "hello"
        frm.set_value("mydata", data);
    });

I create a custom print format for sales invoice which contains:

{{doc.mydata}}

value is appear perfectly in the normal view as below.

But in Print, Fullpage, PDF it shows none.

.

Am i miss something ?

I also checked with server, client js Print Format Type. Anybody pls help ?

1 Like

Did you find any solution?

you can write in “.py” file in init method
like

class YourDocTypeName(Document):
    def __init__(self):
        self.mydata = "Hello"

No Need to add in customize js file.
if you any change in js file that doesn’t get print or PDF, because print or PDF receive ‘doc’ object from direct your DocType class not from js.

#Otherwise
you need to set value from your custom javascript and need to “Save Doc”
like
cur_frm.save()