Zoeken in deze blog

Posts tonen met het label JavaScript. Alle posts tonen
Posts tonen met het label JavaScript. Alle posts tonen

maandag 4 oktober 2010

2011 – Hide Areas of a Form

These code snippets will hide specific areas of the 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

dinsdag 7 september 2010

Een sectie open- of dichtklappen

Met onderstaand script creëer je een sectie die je open- of dicht kunt klappen:

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

if(document.getElementById('navWriteInProducts') != null)
{
document.getElementById('navWriteInProducts').style.display="none";
}

Alle velden op een form op read-only zetten

Om in één keer alle velden op een formulier op read-only te zetten (bijvoorbeeld na wijziging van een status), gebruik je onderstaand JavaScript:

for(var index = 0; index <>
if(crmForm.all[index].Disabled != null)
crmForm.all[index].Disabled = true;

Items uit een picklist hiden

Om items uit een picklist te hiden, gebruik je onderstaand JavaScript:

//Onzichtbaar maken picklist items
crmForm.all.CFPOrderstatus.DeleteOption(2);
crmForm.all.CFPOrderstatus.DeleteOption(5);

Opmaak vast telefoonnummer wanneer land = Nederland

//OPMAAK TELEFOONNUMER BIJ LAND = NEDERLAND

PhonenumberFormat = function()
{
if(crmForm.all.cov_landid_ba.DataValue != null)
{
LookupItem = crmForm.all.cov_landid_ba.DataValue;
if(LookupItem[0].name == 'Nederland')
{
var formFld = event.srcElement;var TelNo = "";
if(formFld.DataValue != null)
{
TelNo = formFld.DataValue.replace(/[^[0-9]/g, "");
}
else
{
return;
}
if(TelNo.substr(0,2) == "31")
{
var TelNo = "0" + TelNo.substr(2);
}
if(TelNo.substr(0,4) == "0031")
{
var TelNo = "0" + TelNo.substr(4);
}
if(TelNo.length > 9)
{
switch (TelNo.substr(0,3))
{
case "010":
case "013":
case "015":
case "020":
case "023":
case "024":
case "026":
case "030":
case "033":
case "035":
case "036":
case "038":
case "040":
case "043":
case "045":
case "046":
case "050":
case "053":
case "055":
case "058":
case "070":
case "071":
case "072":
case "073":
case "074":
case "075":
case "076":
case "077":
case "078":
case "079":
case "085":
case "088":

formFld.DataValue = "(+31)" + " " + TelNo.substr(1,2) + " " + TelNo.substr(3,3) + " " + TelNo.substr(6,2) + " " + TelNo.substr(8,2);
break;

default:formFld.DataValue = "(+31)" + " " + TelNo.substr(1,3) + " " + TelNo.substr(4,2) + " " + TelNo.substr(6,2) + " " + TelNo.substr(8,TelNo.length-8);
break;
}
}
}
}
}

maandag 6 september 2010

Selectievakje (bit-veld) reageert niet op scripting

Wanneer je aan een selectievakje (bit-veld) een JavaScript koppelt, gaat het script niet af wanneer je het desbetreffende vinkje aan- of uitzet. Alleen door met tab het veld te verlaten, zal het script afgaan. Door onderstaand script te gebruiken in de OnLoad van het formulier, wordt dit gedrag afgevangen:

crmForm.all.cov_adverteerder.onclick = function()
{
crmForm.all.cov_adverteerder.FireOnChange();
}

Focus op een tab zetten

crmForm.all.tab1Tab.click();

Veld in hoofdletters

if(crmForm.all.address1_city.DataValue != null)
{
crmForm.all.address1_city.DataValue = crmForm.all.address1_city.DataValue.toUpperCase();
}

Eigenschappen van een lookup field uitvragen

In onderstaand voorbeeld zie je hoe je de verschillende eigenschappen van een lookup field kunt uitvragen:

function HandleOnChangeLookup()
{
if(crmForm.all.primarycontactid.DataValue != null)
{
var lookupItem = new Array;
lookupItem = crmForm.all.primarycontactid.DataValue;
 // The text value of the lookup.
alert(lookupItem[0].name);

// The GUID of the lookup.
alert(lookupItem[0].id);

// The entity type name.
alert(lookupItem[0].typename);

// The entity type code of the lookup: 1=account, 2= contact.
alert(lookupItem[0].type);
}
}

donderdag 26 augustus 2010

Hiden van een sectie

Sectie hiden:
crmForm.all.department_c.parentElement.parentElement.parentElement.style.display = 'none';

Sectie tonen:
crmForm.all.department_c.parentElement.parentElement.parentElement.style.display = 'block';

Een pop-up tonen

alert("Hello!");

Beperken selectiemogelijkheden in een lookup

crmForm.all.regardingobjectid.lookuptypes = "1,2";
crmForm.all.regardingobjectid.lookuptypeIcons = "/_imgs/ico_16_1.gif:/_imgs/ico_16_2.gif";
crmForm.all.regardingobjectid.defaulttype = "2";

woensdag 25 augustus 2010

Standaard waarde in een lookup

var lookupItem = new Array();
lookupItem[0] = new LookupControlItem ("{3415DFD3-E170-DC11-A99F-0003FFB35B1C}", 4001, "Klachtenafhandeling");

crmForm.all.serviceid.DataValue = lookupItem;

Pagina full-screen

window.moveTo(0,0);window.resizeTo(screen.availWidth, screen.availHeight);

Een tab hiden

crmForm.all.tab2Tab.style.display = "none" ;

!!De eerste tab heeft nummer 0!!

Veld read-only maken

Read-only:
crmForm.all.new_textfield.readOnly = true;

Disabled:

crmForm.all.new_textfield.Disabled = true;

Waarde van een lookup wegschrijven in een tekstveld

if(crmForm.all.parentcustomerid.DataValue != null)
{
LookupItem = crmForm.all.parentcustomerid.DataValue;
crmForm.all.new_companyname.DataValue = LookupItem[0].name;
}

Huidige datum wegschrijven in datumveld

crmForm.all...DataValue = new Date();

Vaste datum in datumveld

crmForm.all.requestdeliveryby.DataValue = new Date(2009,0,1);
Let op: de maanden lopen van 0 t/m 11 in JavaScript!