I found a solution that is called AmbekNet.Multiselect option, here is the solution: Solution gitHub
In my CRM(8.2 v1612) i want to block all the fields depending on the selection of another field.
I used javascript for disable all the form, but the multioptionselect is enabled evenly.
The solution of AmbekNet is generating buttons of boolean fields and i try to obtain the webResource and the element button and block it, but it doesn't work.
This is my code of javascript for disable all fields:
function setFieldDisabled() {
var optionset = Xrm.Page.getAttribute("abs_tipodecuenta").getValue();
if (optionset == null)
{
Xrm.Page.getAttribute("abs_tipodecuenta").setValue(100000000);
Xrm.Page.getControl("abs_tipodecuenta").setDisabled(true);
}
if (Xrm.Page.getAttribute("abs_tipodecuenta").getText() == 'Clientes' ||
Xrm.Page.getAttribute("abs_tipodecuenta").getText() == 'Agencias' ||
Xrm.Page.getAttribute("abs_tipodecuenta").getText() ==
'Distribuidores')
{
disableFormFields();
}
else {
enableFormFields();
Xrm.Page.getControl("abs_tipodecuenta").setDisabled(true);
}
}
function disableFormFields()
{
Xrm.Page.ui.controls.forEach(function (control, index) {
var controlType = control.getControlType();
if (controlType != 'iframe' && controlType != 'webresource' &&
controlType != 'subgrid')
{
control.setDisabled(true);
}
});
}
function enableFormFields()
{
Xrm.Page.ui.controls.forEach(function (control, index) {
var controlType = control.getControlType();
if (controlType != 'iframe' && controlType != 'webresource' &&
controlType != 'subgrid')
{
control.setDisabled(false);
}
});
}
And this is the iframe i want to block: MultiSelect
Someone knows how to block it?
Thanks all!
Solved!
In the abr_multiselect.js file i add this line in the method javascript:
function setValue(controlName, value) {
try {
var attr = window.parent.Xrm.Page.getAttribute(controlName);
if (window.parent.Xrm.Page.getAttribute("abs_tipodecuenta").getValue()
== 100000000)
{
alert(value + "guardando");
attr.setValue(value);
attr.setSubmitMode("always");
}
}
catch (e) {
if ( window.console && window.console.log )
console.log("Error: setValue", controlName, e.message);
}
};
Set the value and save only if the field in my case the value is 100000000.