SAVE and Close Function
Save - Xrm.Page.data.entity.save();
Save & Close - Xrm.Page.data.entity.save("saveandclose");
Save & New - Xrm.Page.data.entity.save("saveandnew");
Close - Xrm.Page.ui.close();
Save - Xrm.Page.data.entity.save();
Save & Close - Xrm.Page.data.entity.save("saveandclose");
Save & New - Xrm.Page.data.entity.save("saveandnew");
Close - Xrm.Page.ui.close();
dns_JavaScript/Food.js
Read text box value
Xrm.Page.data.entity.attributes.get("dnsb_foodreason").getValue();
var fName = Xrm.Page.data.entity.attributes.get("fName").getValue();
check value is null or not
if (fName==null) fName = "";
Read text box value
Xrm.Page.data.entity.attributes.get("dnsb_foodreason").getValue();
var fName = Xrm.Page.data.entity.attributes.get("fName").getValue();
check value is null or not
if (fName==null) fName = "";
Get html element value
var plFS = document.getElementById("dns_foodstatus");
remove picklist value
plFS.options.remove(3);
Change Header Title
$('.ms-crm-Form-Title-Label').html(title);
Change Jump Selector Title
$("span.recnav-dropdown").text(title);
Change Document Title
var topTitle = top.document.title;
top.document.title = topTitle.replace("Ineligible Voter Alias", "Felon Audit Alias");
Change Jump Selector Lists Title
$(".ms-crm-RS-Header-Title nobr.ms-crm-RS-Header-Title-Value").text(title);
Hide All the buttons
document.getElementById("mainContainer").style.left = "0px";
Hide Top Bar
window.top.document.getElementById("crmTopBar").style.display = "none";
window.top.document.getElementById("crmContentPanel").style.top = "30px";
window.top.document.getElementById("crmContentPanel").style.top = "30px";
Hide App Message Bar
window.top.document.getElementById("crmAppMessageBar").style.display = "none";
window.top.document.getElementById("crmAppMessageBar").style.top = "0px";
window.top.document.getElementById("crmAppMessageBar").style.top = "0px";
Change Header Top
var headerInfo = "<tbody>";
headerInfo+= " <tr class='ms-crm-Form-Title'>";
headerInfo+= " <td class='ms-crm-Form-LargeIcon-default'>"
$("#crmFormHeaderTop").html(headerInfo);
headerInfo+= " <tr class='ms-crm-Form-Title'>";
headerInfo+= " <td class='ms-crm-Form-LargeIcon-default'>"
$("#crmFormHeaderTop").html(headerInfo);
Get Entity ID
var recordId = Xrm.Page.data.entity.attributes.get("dns_matchbooker").getValue()[0].id
recordId = recordId.replace("{", "").replace("}", "");}
recordId = recordId.replace("{", "").replace("}", "");}
Read pick list value and remove
var plFR = document.getElementById("dns_foodreason");
for (var i=plFR.options.length - 1; i>=0; i--) {
if(plFR.options[i].value != '0' && plFR.options[i].value != '6') {
plFR.options.remove(i);
}
}
for (var i=plFR.options.length - 1; i>=0; i--) {
if(plFR.options[i].value != '0' && plFR.options[i].value != '6') {
plFR.options.remove(i);
}
}
Navigation form selector
document.getElementById("crmFormSelector").style.display = "none";
Hide JumpSelector
document.getElementById("recordSetToolBar").style.display = "none";
Hide Ribbon
setTimeout(function () { window.top.document.getElementById("minimizeribbon").fireEvent("onclick"); }, 0);
Hide Button
top.document.getElementById("dns_book|NoRelationship|Form|DNS.Form.dns_book.MainTab.Save.AssignToDNSStaff-Large").style.display = 'none';
try {
top.document.getElementById("dns_bookalias|NoRelationship|Form|Mscrm.Form.dns_bookalias.MainTab.ExportData").style.display = 'none';
} catch(er) {}
Hide footer
document.getElementById("crmFormFooter").parentElement.style.display = "none";
navigation hide/enable
document.getElementById("crmNavBar").parentElement.style.display = "none";
document.getElementById("tdAreas").parentElement.parentElement.parentElement.style.left = "0px";
document.getElementById("crmNavBar").parentElement.style.display = "";
document.getElementById("tdAreas").parentElement.parentElement.parentElement.style.left = "185px";
document.getElementById("tdAreas").parentElement.parentElement.parentElement.style.left = "0px";
document.getElementById("crmNavBar").parentElement.style.display = "";
document.getElementById("tdAreas").parentElement.parentElement.parentElement.style.left = "185px";
field visible/Disable
Xrm.Page.getControl("lName").setVisible(false);
Xrm.Page.getControl("dns_foodstatus").setDisabled(true);
Xrm.Page.getControl("dns_foodstatus").setDisabled(true);
Tab hide
/*var tabs = Xrm.Page.ui.tabs.get();
for (var i in tabs) {
var tab = tabs[i];
if (tab.getName() != 'tab_general') {
tab.setVisible(false);
}
tab.sections.forEach(function (section, index) {
//alert(section.getName() );
if (section.getName() != 'section_registration_status_update') {
section.setVisible(false);
}
});
}*/
for (var i in tabs) {
var tab = tabs[i];
if (tab.getName() != 'tab_general') {
tab.setVisible(false);
}
tab.sections.forEach(function (section, index) {
//alert(section.getName() );
if (section.getName() != 'section_registration_status_update') {
section.setVisible(false);
}
});
}*/
Alignment Label {
document.getElementById('dns_foodreason_c').style.textAlign = "right";
document.getElementById('dns_foodstatus_c').style.textAlign = "right";
}
document.getElementById('dns_foodstatus_c').style.textAlign = "right";
}
Assing Status Value {
Xrm.Page.data.entity.attributes.get("dns_foodstatus").setValue(1);
//A field that is marked as readonly will not be submitted to the database for update.
//To get the value of a readonly field saved to CRM, you need to use the following code
Xrm.Page.getAttribute("dns_foodstatus").setSubmitMode("always");
}
//A field that is marked as readonly will not be submitted to the database for update.
//To get the value of a readonly field saved to CRM, you need to use the following code
Xrm.Page.getAttribute("dns_foodstatus").setSubmitMode("always");
}
AddTitleSuffix
function AddTitleSuffix(flms) {
//span inner text => innerText
var titleSpan = document.getElementById('form_title_div');
if(titleSpan) {
for(var i = 0;i < titleSpan.children.length;i++) {
if(titleSpan.children[i].className == 'ms-crm-Form-Title-Data autoellipsis') {
titleSpan.children[i].innerText = flms;
}
}
}
}
//span inner text => innerText
var titleSpan = document.getElementById('form_title_div');
if(titleSpan) {
for(var i = 0;i < titleSpan.children.length;i++) {
if(titleSpan.children[i].className == 'ms-crm-Form-Title-Data autoellipsis') {
titleSpan.children[i].innerText = flms;
}
}
}
}
CloseForm
function CloseForm(){
//Xrm.Page.getAttribute("dns_foodid").setSubmitMode("always");
//Xrm.Page.getAttribute("dns_fooditemid").setSubmitMode("always");
Xrm.Page.ui.close();
//avoid dialog box display
//Xrm.Page.ui.detachCloseAlert();
//Xrm.Page.data.entity.detachCloseAlert();
}
//Xrm.Page.getAttribute("dns_foodid").setSubmitMode("always");
//Xrm.Page.getAttribute("dns_fooditemid").setSubmitMode("always");
Xrm.Page.ui.close();
//avoid dialog box display
//Xrm.Page.ui.detachCloseAlert();
//Xrm.Page.data.entity.detachCloseAlert();
}
HeaderChange
function HeaderChange() {
//div inner text FF => textContent
//div inner text IE => innerText
DivUpdate(document.getElementById('header_dns_foodreason_d').children[0], Xrm.Page.data.entity.attributes.get("dns_foodreason").getText());
DivUpdate(document.getElementById('header_dns_foodstatus_d').children[0], Xrm.Page.data.entity.attributes.get("dns_foodstatus").getText());
}
//div inner text FF => textContent
//div inner text IE => innerText
DivUpdate(document.getElementById('header_dns_foodreason_d').children[0], Xrm.Page.data.entity.attributes.get("dns_foodreason").getText());
DivUpdate(document.getElementById('header_dns_foodstatus_d').children[0], Xrm.Page.data.entity.attributes.get("dns_foodstatus").getText());
}
DivUpdate
function DivUpdate(elem, val) {
if ((elem.textContent) && (typeof (elem.textContent) != "undefined")) {
elem.textContent = val;
} else {
elem.innerText = val;
}
}
if ((elem.textContent) && (typeof (elem.textContent) != "undefined")) {
elem.textContent = val;
} else {
elem.innerText = val;
}
}
No comments:
Post a Comment