Merge pull request #374 from asbasawaraj/custom_script_dynamic_options

Added custom script example to limit options in select field dynamically
This commit is contained in:
Nabin Hait
2018-12-31 12:38:40 +05:30
committed by GitHub
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