How to write Server Script?

I have one doctype is A,
which have child table field F,
child table name is C

child table and parent doctype both have “status” named select field and same options

i want to script when i select “Complete” option in A doctype in “status” field

child table’s all row’s “status” field will be updated to “Complete” option before saving the docs

Thank You ! in advance

@nilpatel42 you need client script

frappe.ui.form.on('DocType A',  {
    status: function(frm) {
        if (frm.doc.status=="Complete"){
          for (var i=0;i<frm.doc.table_name.length;i++){
1 Like

sorry @bahaou

i don’t want complex it, that’s why i don’t given my purpose,

basically i want reverse of that, if i have 3 row in child table and all are in “In Progress” status default so parent doctype status field set as “In Progress”

after that when select one row status field to “Complete”, parent doctype status set as “Partially
Complete” and when one of them row’s status set as “Delivered”, parent doctype status set as “Partially Delivered”

This is my complex requirement :smiley:

if you can with client script then i ready try, and also answer that above script not working for me

thank you :pray:

@nilpatel42 you can use the same script but flip the doctypes . write the client script in doctype A forum but use frappe.ui.form.on('DocType B, where DocType B is the name of the child table doctype . use same trigger status . now the event will be triggered whenever you change status in one of the rows. next you can build your logic and switch parent status accordingly .
check forum scripts documentation.