I have implemented the following script to set my field as read-only on a CRM form upon saving it. My requirement is that the field should be editable for the user the first time, and once they select a value and save the form, it should become read-only for subsequent times. However, with the current script, refreshing the form makes the field editable again.
function Test() {
debugger;
Xrm.Page.ui.controls.get("new_test").setDisabled(true);
Xrm.Page.data.entity.attributes.get("new_test").setSubmitMode("always");
//Xrm.Page.getAttribute("new_test").setSubmitMode("always");
Xrm.Page.data.entity.save();
}