Hi everyone,
I'm new to Dynamics so please don't be too judgy.
I have a problem with creating a dependency between two fields. The objective is:
I have two option set fields - A and B. In field A I can choose from option A1 and A2. In field B I can choose from option B1 to B6.
The option I can choose in field B should depent on the option I select in field A. I give you an example:
If A1 is selected, I can only select B1, B2 and B3.
If A2 is selected, I can only select B4, B5 and B6.
Is this possible just with configuring the fields and the form? Is some kind of table necessary and if yes how do I integrate it in my form?
I hope my question is understandable.
Thank you!
I missed the option in the properties until I updated the form "main" in B by including entity A.
Sry, if you described this. I don't unterstand Dynamics too well yet.
Thank you all for your help.
If you open the lookup field for B on the form that needs B to filter, there is a related records filter you can use, like the image below.
Hi Mehdi,
thank you very much for your answer.
I have to admit, your solution is a bit too complicated for me.
I try Mike Hastings suggestion but I appreciate your effort.
Thank you for your enormous support!
Hi Mike,
thank you very much, you answers helps me a lot.
I configured the entities and lookup fields like you described it but in can't find where to set up the filter for B based on what I select on A.
Do I use a business rule or do I configure the lookup field properties in the form?
Again, thank you!
Hello,
First, welcome to the Dynamics community. All questions are more than welcome, we are all here to learn and share our knowledge.
It is possible to implement your scenario using JavaScript code as the field type used is OptionSet. We could have implemented your scenario with a simple configuration if the Field type were a LookUp.
I implement a generic method using JavaScript Code that you can use for every two dependents OptionSets.
if(typeof(MEA)=="undefined"){MEA={}}; if(typeof(MEA.OptionSet)=="undefined"){MEA.OptionSet={}}; if(typeof(MEA.OptionSet.Utilities)=="undefined"){MEA.OptionSet.Utilities={}}; MEA.OptionSet.Utilities = { //Cascading Utility optionSetBValues : null, Cascade: function (executionContext, optionAName, optionBName, dependecies) { var formContext = executionContext.getFormContext(); var selectedAValue = formContext.getAttribute(optionAName).getValue(); var optionSetBControl = formContext.getControl(optionBName); if (optionSetBValues == null) optionSetBValues = optionSetBControl.getOptions(); if (selectedAValue != null) { optionSetBControl.clearOptions(); var dependeciesB = dependecies.find(d => d[0] == selectedAValue).slice(1); var filtredOptionB = optionSetBValues.filter(v => dependeciesB.includes(v.value)); filtredOptionB.forEach(d => { optionSetBControl.addOption(d); }) } else { optionSetBControl.clearOptions(); } } }
Config:
OnLoad:
onChange :
Now, Let's take the following scenario:
OptionA
OptionB:
If A1 is selected. Only B1, B2, B4 can be selected.
If A2 is selected. Only B3, B5, B6 can be selected.
The handler properties will be:
Comma separated list of parameters:
"mea_optionacode","mea_optionbcode",[[1,1,2,4,[2,3,5,6
"mea_optionacode": optionA schemaName.
"mea_optionbcode": optionB schemaName.
[[1,1,2,4,[2,3,5,6: Array containing the dependecies:
beside the suggestion to use entities instead optionset fields to handle this requirement (as Mike Hastings suggested), if you have already the optionset fields you can try my Dependent Option Set Manager (DOSM) solution
demo: guidopreite.github.io/.../
source: github.com/.../DOSM
download: github.com/.../releases
You have a few options - you can use javascript (but that would be outside of configuration)
If you want to configure it, you can create two entities - A and B. Create your A1 and 2 in entity A, then B1-6 in entity B.
- Create a 1:N relationship from A to B, populate records B1, B2, and B3 with the lookup field to A1, do the same for the rest. Now your data is setup.
On the original entity (not A or B) make two lookup fields, one to A and one to B. Then on the lookup field for to entity B you can filter based on the what is picked in lookup to entity A.
Let me know if I confused you nd ill grab a screenshot.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,522 Super User 2024 Season 2
Martin Dráb 228,441 Most Valuable Professional
nmaenpaa 101,148