So this is what I am trying to do.
I have a form: Modalities, that is just a list of names basically, Modality_Names. i.e. Massage, Acupuncture, Personal Training, Rolfing, etc.
Second form: Company, in which there is a lookup field (Modalities_Selected) linked to Modalities and allows multi select. i.e. Company.Modalities_Selected would be a list like Acupuncture,Rolfing
My third form: Service_Providers, needs a field so they can only choose from the subsection specified by the Company.Modalities_Selected. i.e. Service provider one chooses Acupuncture, Service provider two chooses Rolfing, and Service provider three chooses Acupuncture,Rolfing
My question is what is the best way to do this? Use a lookup field and filter on the Service_Provider form, or just a multi select field and add each option, or another way I haven't thought of?
I'm not sure if the best way to do this, but this is what I came up.
Using a multi select field on the Service_Providers form and adding each of the Modality_Names as an option. This occurs on user input for another lookup field to Choose your Company.
- //When user selects their company from Choose your Company (Service_Providers_Company)
- //fill the Modalities pick list so the Service Providers can only choose from those their Companies.Modalies_Selected
- //get a list of the Modality ID's that the Company has chosen
- mod_ID_list = (Company[ID == input.Service_Providers_Company].Modalities_Selected).getall();
- //For each modality ID, Get the Modality Name from the Modalities form based on the ID
- for each opt in mod_ID_list
- {
- //Get Modality Name based on each ID in the list
- mod_name = Modalities[ID == opt].Modality_Name;
- //Add each Modality Name to the Pick list for the Service Provider to choose from
- SP_Modalities_Offered:ui.add(mod_name);
- }
Let me know if clarification is needed. Cheers.