function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Team CirrusTeam 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 :)
Sanjay Bhati 95Sanjay Bhati 95
Hi Team,

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
Abhishek BansalAbhishek Bansal
Hi,

You need to follow the below steps in order to complete your requirements:
  1. Override the new button for Patient objec with a new visualforce page or lightning component.
  2. In this new page or component, you need to add an onchange method for the Hospital field.
  3. In this onchange method you need to query the ward type field value from the wards object related to that Hospital.
  4. 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.
Ivory TollersIvory Tollers
Choose the best German clinic for you if you want to look and feel your best. For this, visit https://bookinghealth.com/ to learn more about the options available. An competent dermatologist who specializes in hair restoration will attempt to determine the root cause of your problem rather than simply treating the outward symptoms. The finest German clinics offer a comprehensive range of effective hair restoration treatments, including hair transplantation.