RE: Allow access to a single field on an opportunity
Hi rswaans,
By default, the 'field security' option is 'disabled' for all fields of the opportunity entity.
If you want to use field level control, you have to enable it for all fields excluding a specific field.
Maybe you can try to use js to disable/enable one field based on the security role:
(1)Js Code:
If current use has the specific security role, lock all controls of the form, then unlock the specific field again.
function disableField (execContext) {
var formContext = execContext.getFormContext();
var userSettings = Xrm.Utility.getGlobalContext().userSettings;
//Get Security Roles of the current User
var securityRoles = userSettings.securityRoles;
//Below is the GUID of the Security Role "Account Manager"
var securityRoleId = "A39E17FE-12AB-E411-80D9-00155DB98105";
////No argument returns all controls on the form
var formControls = formContext.getControl();
for (i = 0; i < securityRoles.length; i ) {
//If current User contains the Required Security Role
if (securityRoles[i].toUpperCase() == securityRoleId.toUpperCase())
{
//Lock all controls
formControls.forEach(control => {
control.setDisabled(true);
});
//unlock the specific field
formContext.getControl("description").setDisabled(false);
}
}
}
(2)Add js as web resource, then add to opportunity form.
Save and publish all customizations.