Hello,
I have 2 docTypes. NGO (id, name, state, address, mobile), and NGO_STATUS( ngo_id, ngo_name, ngo_state, ngo_status)
In NGO_STATUS, ‘ngo_id’ is a link to NGO
.
When i select a particular ngo in the NGO_STATUS.ngo_id, the ngo_name and ngo_state should be auto filled based on the selected ngo_id.
Is this possible. Pls let me know.
I read about dynamic link, but it seems to be different than what i need.
Both my states_list and country fields are “SELECT” type fields. I need to return corresponding states when a country is selected.
//Return states list based on country. I think i need something like this. But i am sure that the way i am returning the state_list is wrong. Can someone point me out to an existing code, or some tutorial. Tried frappe doc, may be i missed it though
cur_frm.cscript.custom_validate = function(doc) {
// clear states_list , which is a SELECT type list
doc.states_list = “”;
// Returns states based on country
switch(doc.country_name) {
case "India":
doc.states_list = "Delhi, Assam,AP, TN";
break;
case "USA":
doc.states_list = "Texas, California, MD, MS, WDC";
break;
default:
doc.states_list = "error";
}
Thank you @Sangram . I tried to change the script as per your suggestion. But the states list dont get updated automatically when a country is selected. Should i be using “cur_frm.cscript.custom_validate” or something else. Can you pls point me to some code.
Thank you very much for your help. I was able to get it working. But for some reason, in the above code did not work, it said village_map.get() does not exist. So i made some changes to remove the get function.