Announcements
I have a option set column called "Business Unit" and the options are
"Edge"
"Core"
"Cloud"
Then I have another option set column called "Business category" and the options are
"Hardware"
"Software"
"Services"
If I select any option on "Business Unit" then the dropdown from "Business Category" should pop up based on the option, I selected in "Business Unit"
For eg:-
1. If I select "Edge", then only "Hardware" should pop up
2. If I select "Core" then "Hardware" and "Software" should pop up
3. f I select "Cloud" then "Hardware" and "Software" and "Services" should pop up
We are trying with JScript in CRM, but it is showing some error. Can anyone help me out how to write a script to achieve this process. I have to do this on priority.
Rajath,
As i already told selecting an option and adding an option are different.
Do you want to select an option or add an option to the option set?
If you found this useful, like or verify my answer. That keeps me motivated
Hi Tamilarasu,
I am trying an alternative way mentioned in internet using array, can you help me out where I'm wrong as I'm getting an error.
var B_line_arr = window.B_line_arr || {};
(function() {
this.formOnLoad = function (executionContext){
var formContext = executionContext.getFormContext();
var businessarea = formContext.getAttribute("new_buniessarea21").getText();
var businessline = formContext.getAttribute("new_buniessline21")
if(businessarea=="Edge")
{
var arr = [{value: 100000000, text: 'Hardware'},
{value: 100000001, text: 'Software'},
{value: 100000002, text: 'Services'}];
for(var i=0;i<=arr.length;i++)
{
businessline.clearOptions();
businessline.addOption({value: arr[0].value, text: arr[0].text});
}
}
}
}).call(B_line_arr)
Error info
As per my understanding to your question. By default the values from Multi-select optionset is in the form of array. you can set your value to this array as i did.
Sure I will use that SeValue() option , but can you help me to achieve the same using array as it will enhance the code and number of lines will be reduced.
Rajath,
I think you don't need to use addOption() because it adds new option to optionset, you have to use setValue() as i did in my code
Please verify my answer, if you found it useful
Hi Tamilarasu,
Thank you for your help, I got my script and it's working now. Can you pls suggest me how to write the same script using array concept? as it will enhance the script.
I am pasting my script here, pls tell me how to achieve using array
var B_line = window.B_line || {};
(function() {
this.formOnLoad = function (executionContext){
var formContext = executionContext.getFormContext();
var businessarea = formContext.getAttribute("new_buniessarea21").getValue();
var businessline = formContext.getAttribute("new_buniessline21")
if (businessarea == "Edge")
{
businessline.clearOptions();
businessline.addOption({value: 100000000, text: 'Hardware'});
businessline.addOption({value: 100000001, text: 'Software'});
businessline.addOption({value: 100000002, text: 'Services'});
}
if (businessarea == "Core")
{
businessline.clearOptions();
businessline.addOption({value: 100000000, text: 'Hardware'});
businessline.addOption({value: 100000001, text: 'Software'});
businessline.addOption({value: 100000002, text: 'Services'});
businessline.addOption({value: 100000003, text: 'Software Subscription'});
}
if (businessarea == "Cloud")
{
businessline.clearOptions();
businessline.addOption({value: 100000001, text: 'Software'});
businessline.addOption({value: 100000002, text: 'Services'});
}
}
}).call(B_line)
Hi Rajath,
As of now Business rules does not support setting values to the Multi select option set field. So, you can do it with JavaScript. The below code JavaScript might help you
function optionSetPopup(executionContext){ var formContext=executionContext.getFormContext(); var businessUnitValue=formContext.getAttribute("comp_bunit").getValue(); var businessCategoryValue=formContext.getAttribute("comp_bcat"); switch(businessUnitValue){ case 528830000: businessCategoryValue.setValue([528830000]); break; case 528830001: businessCategoryValue.setValue([528830000,528830001]); break; case 528830002: businessCategoryValue.setValue([528830000,528830001,528830002]); break; } }
If this helps you, please verify my answer
You can use DOSM (Dependent Option Set Manager)
https://github.com/GuidoPreite/DOSM
Install the managed solution and launch the app
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156