Custom Script to update custom field value based on status value from Sales Invoice

Hi Hello All,

I applied this custom script to the doctype “Quotation”


My goal is to get the value of status field from “Sales Invoice” the value (Unpaid , Paid) and update to my “payment_status” custom field in the quotation.

I created the custom fields in “Quotation” doctypes.

However, it’s not working. What am I missing?


sales_invoice is not a field from quotation, do you create it? If you do, is it a Link field?

Thanks Nahuel_Nso
sales_invoice is doctype it is not a field, what i want to to achieve is to fetch the current value of status field from Sales Invoice doctype and set to the payment_field value in the Quotation doctype. My goal is to add Payment Status column in the Quotation list with the current value of status field from Sales Invoice doctype

The format of the add_fetch function is this:

cur_frm.add_fetch("<LINK_FIELD>", "<FIELD_IN_OTHER_DOCTYPE>", "<RESULT_FIELD>")

So, you need have almost every part correct, you just need a link to the sales invoice in the first argument. Does quotation have a link field for sales invoice? If yes, you should put the fieldname there.

You mean Sir, the payment_status field type from the Quotation doctype is link? and in the Option I will put Sales Invoice? Can you please guide me the step what need to be done. Thanks

Well, as I can see, there is no reference to the Sales Invoice in the Quotation DocType, so, you have to make a field in quotation that will contain the reference to the Sales Invoice, and then, your code will look like this:

cur_frm.add_fetch("<NEW_FIELD_NAME>", "status", "payment_status")

Im confuse to the <LINK_FIELD> is this a Sales Invoice doctype?

This is the documentation for Link Fields:

So, From the Quotation doctype i will make a fieldame could Invoice Quote field type is link and Option Sales Invoice is this what you mean sir?

I think it is, yes.

Thank you so much sir, really appreciate your time and help

Is not working sir, I tried the configuration below, I don’t know what I am missing for my config. Honestly I don’t know the doctype name of Sales Invoice is right

You can try this:
To the payment_status field, add this to the field “Fetch From”:


Same not working sir, is my Sales Invoice doctor is correct?

Has anyone achieved this ? I would like to do it as well.