Question: How to lock a field if a another field contains data?
Answer : For example we have a lookup field as parentcustomerid and a country name as another field.so if the parentcustomerid has data then the field should be lock if the parentcustomerid does not have the data then it should get unlock.Here comes the code
function lockfield()
{
var field = Xrm.Page.getAttribute("parentcustomerid").getValue();
if (field != null) {
Xrm.Page.getControl("sample_countryname").setDisabled(true);
}
else
{
Xrm.Page.getControl("sample_countryname").setDisabled(false);
}
}
Answer : For example we have a lookup field as parentcustomerid and a country name as another field.so if the parentcustomerid has data then the field should be lock if the parentcustomerid does not have the data then it should get unlock.Here comes the code
function lockfield()
{
var field = Xrm.Page.getAttribute("parentcustomerid").getValue();
if (field != null) {
Xrm.Page.getControl("sample_countryname").setDisabled(true);
}
else
{
Xrm.Page.getControl("sample_countryname").setDisabled(false);
}
}
No comments:
Post a Comment