Hi,
Can we set the Mutliselect option field value into a single line of text using javascript in D365 CRM?
Please help if someone has any idea.
Thanks.
Hi,
Can we set the Mutliselect option field value into a single line of text using javascript in D365 CRM?
Please help if someone has any idea.
Thanks.
Thanks!! It gave me expected result.
Hi,
Thank you for your query.
As per my understanding, you need to set selected options (text) in a single line text field (comma separated).
Here is the sample code:
function setOptionsToSomeField(executionContext) { const formContext = executionContext.getFormContext(); //get the selected options (text) var selectedTexts = formContext.getAttribute("gb_multiselect").getText(); //convert selected options to comma seperated string var stringValue = selectedTexts.join(); // Set this value to a single line text formContext.getAttribute("new_sometext").setValue(stringValue); }
Register this function on change of the Multi-select optionset, and do not forget to pass Execution context as the first parameter.
Related docs:
getText (Client API reference) in model-driven apps - Power Apps | Microsoft Docs
Hello CRMQQ!
In order to set the values for a Multiselect option field, you have two ways:
1. Using Microsoft Dataverse Web API:
// On the parameter object, you add the following property: { "new_multiselectField": "1, 9" // 1 and 9 are the values of the options you want to select, if you just want one, simply add the value of that option }
2. Using formContext
//You create an array containing the values of the options you want to select formContext.getAttribute("new_multiselectField").setValue([100000003, 100000004]);
Here you also have two guides with more information about the topic: Option 1 (using Web API), Option 2 (using formContext)
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,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156