mirror of
https://github.com/erpnext/foundation.git
synced 2026-10-16 18:00:47 +02:00
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:
@@ -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}
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user