Custom script works only once

Hi community,

I am new to ERPnext and trying to learn step by step. Now, I have following problem:

I have a custom script at Quotation and a custom field called “angebotsid” in Quotation and User that I want to use in a naming series. I use the custom script to retrieve the “angebotsid” of the current user for a new quotation. This works, but always only for the first quotation. At the second one, the field is empty again and the user has to input manually or logout/login.

Can you help my out? Any hints or ideas?

My script:

var Current_User = user;
frappe.call({
method:“frappe.client.get”,
args: {
doctype:“User”,
filters: {‘email’: Current_User
},
},
callback: function(r) {
cur_frm.set_value(“angebotsid”,r.message.angebotsid)
}
})

First quotation:

second quotation:

Thank you in advance.

Johannes

frappe.ui.form.on(“Quotation”, {
refresh: function(){
//your code will be fired everytime form refresh
}
})

HI Magic,

Thanks a lot.

Do I have to place this in my custom script for quotation or elsewhere?

Thanks,
Johannes

In your Quotation custom script.