Hi,
Try to add alert in your code to see what is happening. Please see below code -
function sample() {
// Obtain the User ID from context of the page
var UserId = Xrm.Page.context.getUserId();
alert("Original User ID"+UserId );
var UserName = Xrm.Page.context.getUserName();
UserId=UserId.replace('{','').replace('}','');
alert("After Replace User ID"+UserId );
// Check for User Id match
if (UserId == "A45413E2-2B07-EB11-A812-000D3A0C2AB4") {
// Set field to Disabled
alert("Condition satisfied");
Xrm.Page.getControl("fieldName").setDisabled(true);
}
else {
alert("Condition Not satisfied");
// Leave as is
}
}
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/