Changing a value in different document

I created a new docType for programming receipt in this document there is a link field for Serial No.
In addition, I added a read-only checkbox for Serial No built-in document called “Programmed” which is by default false.

The problem is how to write a script for the custom document so when it is submitted it check the said checkbox of the serial no

more explanation:

So basically you are mapping and existing serial number to a document in your custom doctype, and you want to show if there exists a document with this serial number in your custom doctype.
You have 2 options:

  1. Use frappe.db.set_value upon submission of your custom doc to set the custom field in the serial number doctype to 1. see this( If you go through that route, you’ll also have to handle the on_cancel event.

  2. A simpler solution would be to write a custom script in the serial no doctype and upon refresh, check if there are any records in the custom doctype using frappe.db.count, and if there are any set the checkbox to one. see this (

If you need help with the script let me know.

Thank you. I tried the second option. it worked. but only one problem, the check only appears when I open the serial number, and it never saves it as checked. which also results in not appearing in the filter.

Yep, filters would be a problem in the second option.
set_value would fit better in that case