Set Managed Metadata field to readonly
Posted: 06 Feb 2019
Hello,
I've been trying to test the ability to make fields readonly based on a field condition. The following code seems to work just fine except when the field is a managed metadata field such as "Office":
function setBusinessCaseLockdown() {
if (fd.field('BusinessCaseLock').value() == 'Locked') {
// Getting JQuery-object of Business Case Form fields and disable them
fd.field('Title').readonly(true);
fd.field('Office').readonly(true);
fd.field('Division').readonly(true);
fd.field('Branch').readonly(true);
fd.field('ProjectGoals').readonly(true);
fd.field('Objectives').readonly(true);
fd.field('Scope').readonly(true);
fd.field('Scope1').readonly(true);
} else {
// Getting JQuery-object of the field and enable it
fd.field('Title').readonly(false);
fd.field('Office').readonly(false);
fd.field('Division').readonly(false);
fd.field('Branch').readonly(false);
fd.field('ProjectGoals').readonly(false);
fd.field('Objectives').readonly(false);
fd.field('Scope').readonly(false);
fd.field('Scope1').readonly(false);
}
}
I've tried using the following code for office like this but it doesn't seem to work:
fd.field('Office').control()._el().find('.ms-taxonomy').readonly(true);
Any suggestions?
I've been trying to test the ability to make fields readonly based on a field condition. The following code seems to work just fine except when the field is a managed metadata field such as "Office":
function setBusinessCaseLockdown() {
if (fd.field('BusinessCaseLock').value() == 'Locked') {
// Getting JQuery-object of Business Case Form fields and disable them
fd.field('Title').readonly(true);
fd.field('Office').readonly(true);
fd.field('Division').readonly(true);
fd.field('Branch').readonly(true);
fd.field('ProjectGoals').readonly(true);
fd.field('Objectives').readonly(true);
fd.field('Scope').readonly(true);
fd.field('Scope1').readonly(true);
} else {
// Getting JQuery-object of the field and enable it
fd.field('Title').readonly(false);
fd.field('Office').readonly(false);
fd.field('Division').readonly(false);
fd.field('Branch').readonly(false);
fd.field('ProjectGoals').readonly(false);
fd.field('Objectives').readonly(false);
fd.field('Scope').readonly(false);
fd.field('Scope1').readonly(false);
}
}
I've tried using the following code for office like this but it doesn't seem to work:
fd.field('Office').control()._el().find('.ms-taxonomy').readonly(true);
Any suggestions?