You need to sign in to do that
Don't have an account?
Team Cirrus
How to render picklist values according to those available in the related object?
I am a newbie to salesforce and I am doing a project on hospital management system in it. I have Objects for Hospitals, Wards & Patients. Patient is in a lookup relationship with Ward and Hospital. In Ward I have a picklist called ward type(values: General, ICU, HCU, ICCU, Cabin). In Patient Object I also have a similar picklist called ward type but here I want to display only those wards which are available in the hospital where the patient is getting admitted(for e.g, ICCU and HCU are not present in every hospital so it is meaningless to show those options in ward type of such hospitals while filling a new patient detail).
Other than salesforce I could query the database of Ward object filtered by hospital name entered and put the options in the drop-down list but I do not know how to put options in picklist in real-time fetching the records of wards, filtered by hospital name entered by the user in salesforce.
Plz help if you know anything in this regard :)
Other than salesforce I could query the database of Ward object filtered by hospital name entered and put the options in the drop-down list but I do not know how to put options in picklist in real-time fetching the records of wards, filtered by hospital name entered by the user in salesforce.
Plz help if you know anything in this regard :)
Please have a look on below example
You can use onchange event on hospital text box. Onchange of text box you can query the ward type and put in a option list.
Filled option list you can use to display select list. on text box you can also use reRender='outputpanelId'.
put picklist in a OutPutPanel Tag and give it outputpanelId
When you select any hospital picklist will automatically filled up with related ward type.
Let me knwo if you have any confusion.
Thanks
You need to follow the below steps in order to complete your requirements:
- Override the new button for Patient objec with a new visualforce page or lightning component.
- In this new page or component, you need to add an onchange method for the Hospital field.
- In this onchange method you need to query the ward type field value from the wards object related to that Hospital.
- Based on the retrieved values you can display those values in the Ward Type field on this new page or component.
Please let me know if you need any help with this new page or component. You can also reach out to me directly:Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790.
Thanks,
Abhishek Bansal.