Auto Repeat uses the “Duplicate” function from the reference document to create new docs automatically. What’s the best way to update things like contact_email?
If I’m using Auto-Repeat to create Sales Invoice, the contact_email get’s pulled from the source doctype. I can’t edit the previous invoice to fix the “cached” email address. This is an issue when changing/updating the billing contact’s email address. It will never get fixed automatically in future invoices.
My workaround is to manually edit the last invoice via the database, then use this doc to update the Auto Repeat source doc.
If I customize Sales Invoice and mark contact_email as “no copy” will this be sufficient? Should contact_email be set to “no_copy” in ERPNext Core as the default?
EDIT: Answering my own question here. This is a lesson so good, it’s worth learning more than once!
I think the most elegant solution is to mark the auto-repeat as “don’t submit”, then when the new invoice is created, I can edit the contact info > submit > update reference doc in the auto-repeat. This means users need to pay attention to any auto-repeat docs related to Contacts/Customers/Addresses/etc when making these types of changes that impact auto-repeat.
Hi @volkswagner — great that you’ve already found a partial answer! Let me give you the full picture of your options, from least to most effort:
Option 1 — Mark contact_email as “No Copy” (Recommended)
This is the cleanest standard-feature solution. In Customize Form → Sales Invoice, find the contact_email field and tick “No Copy”. When Auto Repeat duplicates the invoice, this field will be left blank and ERPNext will re-fetch it from the linked Customer/Contact at the time of creation.
-
Go to Customize Form → select Sales Invoice
-
Find the contact_email row → expand and tick No Copy
-
Save the customization
This is safe and upgrade-proof since it uses the standard customization layer.
Option 2 — Auto-Repeat “Don’t Submit” workflow (your own suggestion)
Setting the Auto Repeat to Don’t Submit Automatically leaves the created invoice in Draft so you can review/edit contact details before submitting. This works well for low-volume use cases where a human touches each invoice anyway.
Option 3 — Server Script to refresh contact on creation
If you want fully automatic refresh without manual steps, add a Server Script (DocType Event: Before Insert, DocType: Sales Invoice) to re-fetch the contact email:
# Before Insert - Sales Invoice
if doc.contact_person:
contact = frappe.get_doc("Contact", doc.contact_person)
for email in contact.email_ids:
if email.is_primary:
doc.contact_email = email.email
break
Hope this helps!
2 Likes
Hi @xlurself
Very well presented answer
Thanks 