I am using below script to make my field read-only on CRM form while saving it. My requirement is for the first time it should be editable for user and once user select value and save the form its should be read-only for the next time. but with below script whenever I am refreshing the form field will become 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();
}
You have to do it in form onLoad
not onSave
. If the picklist already have value selected, then disable it.
Call this formOnLoad()
method in form onLoad
event.
function formOnLoad() {
debugger;
if(Xrm.Page.getAttribute("new_test").getValue() != null){
Xrm.Page.ui.controls.get("new_test").setDisabled(true);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.