Added custom script example to limit options in select field dynamically

This commit is contained in:
Basawaraj Savalagi
2018-12-01 10:52:25 +05:30
parent 8d7f6770cd
commit 421ed06a48
2 changed files with 17 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
# Dynamically Update Options in Select Field
Lets say you have a field named state and another field named city. And you would like to limit options in city based on the values chosen in state field, you can write custom script as shown below.
frappe.ui.form.on("DocType Name Here", "state", function(frm) {
if(frm.doc.state == "Karnataka")
{
set_field_options("city", ["Bangalore","Mysore"])
}
else if(frm.doc.state == "Maharashtra")
{
set_field_options("city", ["Mumbai","Pune"])
}
});
{next}

View File

@@ -8,3 +8,4 @@ restrict-user-based-on-child-record
sales-invoice-id-based-on-sales-order-id sales-invoice-id-based-on-sales-order-id
update-date-field-based-on-value-in-other-date-field update-date-field-based-on-value-in-other-date-field
custom-button custom-button
dynamically-show-options-in-dropdown