Zoeken in deze blog
donderdag 21 oktober 2010
Uitvragen aantal veld (2011)
{
var locAttr = Xrm.Page.data.entity.attributes.get("numberofemployees");
alert(locAttr.getValue());
}
dinsdag 19 oktober 2010
Eigenschappen van een Lookup uitvragen (2011)
{
var LookupItem = Xrm.Page.data.entity.attributes.get("primarycontactid");
if (LookupItem.getValue() != null)
{
// The GUID of the lookup
alert(LookupItem.getValue()[0].id);
// The text value of the lookup
alert(LookupItem.getValue()[0].name);
// The entity type name
alert(LookupItem.getValue()[0].typename;
// The entity type code of the lookup 1=account, 2=contact
alert(LookupItem.getValue()[0].type);
}
}
maandag 4 oktober 2010
2011 – Hide Areas of a Form
// Hide the Ribbon Toolbar and move the form Content area to the top of the window.
window.top.document.getElementById(“crmTopBar”).style.display = “none”;
window.top.document.getElementById(“crmContentPanel”).style.top = “0px”; // Move Form Content area up to top of window, initial style.top is 135px
// Hide Left Hand Nav bar / pane
document.getElementById(“crmNavBar”).parentElement.style.display = “none”;
document.getElementById(“tdAreas”).parentElement.parentElement.parentElement.parentElement.colSpan = 2;
// Hide the Breadcrumb and Record Set Toolbar
document.getElementById(“recordSetToolBar”).parentElement.style.display = “none”;
// Hide the Form Footer Bar
document.getElementById(“crmFormFooter”).parentElement.style.display = “none”;
Original Post by Rhett Clinton
donderdag 9 september 2010
Collapsable Form Sections
function getElementsByCondition(condition, container) {
container = container || document;
var all = container.all || container.getElementsByTagName('*');
var arr = [];
for (var k = 0; k < all.length; k++) {
var elm = all[k];
if (condition(elm, k))
arr[arr.length] = elm;
}
return arr;
}
function attachCollapsableToSections() {
var sections = getElementsByCondition(function (elm) { if (elm.className.indexOf("ms-crm-Form-Section") != -1) return true; }, null);
for (var i = 0; i < sections.length; i++) {
sections[i].innerHTML = '<img alt="Expanded, click to collapse" src="/_imgs/navup.gif" style="cursor:hand;"/>' + sections[i].innerHTML;
sections[i].childNodes[0].attachEvent('onclick', toggleVisibility);
}
}
function toggleVisibility(e) {
var sectionContainer = e.srcElement.parentNode.parentNode.parentNode;
var elements = getElementsByCondition(function (elm) { if (elm.vAlign == "top") return true; }, sectionContainer);
for (var i = 0; i < elements.length; i++) {
if (elements[i].style.display == "none") {
elements[i].style.display = "";
e.srcElement.src = e.srcElement.src.replace("navdown", "navup");
}
else {
elements[i].style.display = "none";
e.srcElement.src = e.srcElement.src.replace("navup", "navdown");
}
}
}
attachCollapsableToSections();
dinsdag 7 september 2010
Custom Warning
/*============== addNotification function =============
Adds a warning message on the top of the entity form using
the same visual style as Microsoft CRM
Params: message to be shown to the user
=======================================================*/
addNotification = function(message) {
var notificationHTML = '<DIV class="Notification"><TABLE cellSpacing="0" cellPadding="0"><TBODY><TR><TD vAlign="top"><IMG class="ms-crm-Lookup-Item" alt="" src="/_imgs/error/notif_icn_crit16.png" /></TD><TD><SPAN>' + message + '</SPAN></TD></TR></TBODY></TABLE></DIV>';
var notificationsArea = document.getElementById('Notifications');
if (notificationsArea == null) return;
notificationsArea.innerHTML += notificationHTML;
notificationsArea.style.display = 'block';
}
/*============= END addNotification function ===========*/
//Example of utilizations
addNotification('Some warning message that you want to show to the user ');
Een sectie open- of dichtklappen
function OnCrmPageLoad()
{
/* false - collapsed, true - expanded */
//First Tab, Second Section, Expanded
ConvertSection(0,1,false);
//First Tab, Third Section, Collapsed
ConvertSection(0,2,false);
}
function ConvertSection( tabIndex , sectionIndex , state ) {
var sec = document.getElementById( "tab" + tabIndex );
var td = sec.childNodes[0].rows[ sectionIndex ].cells[0].childNodes[0].rows[0].cells[0];
var secHTML = td.innerHTML;
state = (typeof(state) == "undefined")? false:!state;
var src = (state == false)? "/_imgs/tree/dashPlus.gif":"/_imgs/tree/dashMinus.gif";
td.innerHTML = "<NOBR style='VERTICAL-ALIGN: middle;cursor:hand' onclick='excoSection(this)'><IMG src='" + src + "' align='middle' /> " + td.innerHTML + "</NOBR>";
td.childNodes[0].childNodes[0].state = state;
excoSection(td.childNodes[0]);
}
/* Toggle SectionState */
function excoSection( sec ) {
sec = sec.childNodes[0];
sec.state = !sec.state;
sec.src = (sec.state)? "/_imgs/tree/dashMinus.gif":"/_imgs/tree/dashPlus.gif";
var display = (sec.state)? "inline" :"none";
var tblsec = sec.parentElement.parentElement.parentElement.parentElement;
for( var i =1 ; i < tblsec.rows.length ; i++ )
tblsec.rows[i].style.display = display;
}
//Expose the toggling function at the window level
this.excoSection = excoSection;
OnCrmPageLoad();
Optie uit de NavBar hiden
{
document.getElementById('navWriteInProducts').style.display="none";
}