How to set background colour and remove border of a field in
CRM 2011 using JavaScript.
The following function can be used to set the background colour and remove border of a field.
function
setBgColorandRemoveBorder(){
//Hide border of field in CRM 2011.
document.getElementById(
"fieldName"
).style.border=
"0px"
;
//Set background colour of text field in CRM 2011.
document.getElementById(
"fieldName"
).style.backgroundColor =
"#f6f8fa"
;
}
How to remove a Picklist Item using javascript?
The following function can be used to remove a picklist item with a particular text from an OptionSet.
function
hideItemFromPiclist(fieldName, textValue){
var
picklist = document.getElementById(
"fieldName"
);
for
(
var
i = picklist.options.length - 1; i >= 0; i--){
var
picklistItemText = picklist.options[i].text;
if
(picklistItemText.match(textValue) == textValue && picklist.selectedIndex != i){
picklist.options.remove(i);
}
}
}
How to Show/Hide left navigation item based on a condition in
CRM 2011? Sometime we might have to hide an item from the left navigation of the
CRM from. The following function can be used to show or hide a left navigation item.
function
ShowBankDetails(){
var
payeeChkBox = Xrm.Page.ui.controls.get(
"new_rolepayee"
);
//new_rolepayee is name of checkbox field.
if
(payeeChkBox.getvalue()){
//new_account_new_bankdetail is name of relationship between account and bankdetail entity.
Xrm.Page.ui.navigation.items.get(
"nav_new_account_new_bankdetail"
).setVisible(
true
);
}
else
{
Xrm.Page.ui.navigation.items.get(
"nav_new_account_new_bankdetail"
).setVisible(
false
);
}
}
Hope this helps. Happy Coding