I know how to create conditional statements but, i have some fields that are multiple option sets.
In my mind i have this planned:
Hi partner,
Yes, but you need to replace the field name and option set value with your owns.
And then just add the JS code into your instance, I provided the steps in my above reply.
Regards,
Leo
i am not familiar with JS coding.
Can i copy your code and and just insert my terms and fields?
Hi partner,
There is no OOB way to do this, and Business Rule also doesn't support this condition.
I recommend you to use JS code to enable this custom condition.
For example, I have two fields on my form:
Option base (option set)
Label Value
A 1
B 2
Multiple condition(multiple option set)
Label Value
Apple 1
Banana 2
Pear 3
Orange 4
Now I want when I choose A in Option Base, only "Pear" and "Orange" are available in Multiple condition, when I choose B, only "Apple" and "Banana" available.
So I created the following code with JS to archive this.
function filterOptions(executionContext){ var formContext=executionContext.getFormContext(); var conditionValue=formContext.getAttribute("new_optionbase").getValue(); var multipleField=formContext.getControl("new_multiplecondition"); if(conditionValue!=null){ //if we select A in conditionField if(conditionValue==1){ multipleField.removeOption(1); multipleField.removeOption(2); //get current options in multiple options var currentOptions=multipleField.getOptions(); if(!checkExisting(currentOptions,3)&&!checkExisting(currentOptions,4)){ multipleField.addOption({value:3,text:"Pear"}); multipleField.addOption({value:4,text:"Orange"}); } } //if we select B in conditionField if(conditionValue==2){ multipleField.removeOption(3); multipleField.removeOption(4); //get current options in multiple options var currentOptions=multipleField.getOptions(); if(!checkExisting(currentOptions,1)&&!checkExisting(currentOptions,2)){ multipleField.addOption({value:1,text:"Apple"}); multipleField.addOption({value:2,text:"Banana"}); } } } } function checkExisting(array, value) { var result = false; array.forEach(item => { if (item.value == value) { result = true; } }) return result; }
To avoid logical errors caused by repeated choices, I added some logical control codes.
Add this function both in form onload event and Option Base onchange event.
Save and publish.
Let's see the results.
When open a new creation form, there are 4 options in multiple condition in default.
When we select A, then only show Pear and Orange.
Select B, only show Apple and Banana.
When you save the record and open it again, this rule is also enabled.
Hope it helps.
Best Regards,
Leo
this should be easier to archive by using JS code register in form onload event
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... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156