Not sure if you could work by index, but if one field is the “master” as in one field is always set first, you could set the other field with if statements and frm.set_value. Wouldn’t even need to be a select field.
It wouldn’t matter if they are different. You could write a custom script that checks a field for value “1”. If value “1” is present then add value “A” to another field. Both lists values would be hard coded in the script and the first field is a select field so users will only enter initial values the script recognizes.
Example custom script:
Doctype name: Doctype
custom1: select field with values 1,2,3
custom2: data field (should probably be read-only)
frappe.ui.form.on("Doctype", {
"custom1": function(frm) {
if (frm.doc.custom1=='1') {
(frm.set_value('custom2', 'A'));
}
else if (frm.doc.custom1=='2') {
(frm.set_value('custom2', 'B'));
}
else if (frm.doc.custom1=='3') {
(frm.set_value('custom2', 'C'));
}
else if (frm.doc.custom1=='') {
(frm.set_value('custom2', ''));
}
}
});
As I said earlier this would work if users are only setting the value on one custom field and the other is always auto set by the script. Which is why the second custom field should be read-only. The second custom field does not need to be a select field since the values are hard coded into the script.
@Dbone this is not work with me , i did like this script exactly
but i can’t change value of field depend on my selection value of another field, check my script and help me please if you can @suyash