Tuesday, December 1, 2009

MARK BUSINESS REQUIRED MANUALLY

Sometimes we need to make the attributes(fields) "Business Required" manually , when the crmForm.SetFieldReqLevel("fieldname", 1); stops working ie any changes has been done in the attribute level.

//for business required which will put a red asterisk side to the attribute
//it only takes one parameter as new_attributeName_c
function markRequired(lbl)
{
if(lbl !=null){
if(lbl.childNodes[0] != null && lbl.childNodes[0].innerText != undefined){
html = lbl.childNodes[0].innerHTML +"<IMG alt='Required' src='/_imgs/frm_required.gif'/>";
}else{
html = lbl.innerHTML +"<IMG alt='Required' src='/_imgs/frm_required.gif'/>";
}
lbl.innerHTML = html;
}
}

//for not business required which will remove the red asterisk side to the attribute
//it only takes one parameter as [i]new_attributeName_c
function markOptional(lbl) {
if(lbl !=null){
if(lbl.childNodes[0] != null && lbl.childNodes[0].innerText != undefined){
html = lbl.childNodes[0].innerText ;
}else{
html = lbl.innerText ;
}
lbl.innerHTML = html;
}


//on save also we need to check it manully and return back to the same form without saving the details and
//the focus need to be on the required attribute(field) provided the field should not be read-only
if(crmForm.all.new_attributeName.DataValue == null){
crmForm.all.tabName.click();
crmForm.all.new_attributeName.focus();
alert("Attribute is Required.");
event.returnValue = false;
return false;
}

//[i]Just some Re-engineering will give a lot

No comments:

Post a Comment