Ajax code equivalent of the @DBColumn formula for Lotus Notes
Learn how to use the Ajax code equivalent of the @DBColumn formula for Lotus Notes, which can be pasted onto events to return the results of a column.
Here is the most recent and updated Ajax code equivalent of the @DBColumn formula for Lotus Notes. By using this, you can select the column of your choice and return the results.
Paste the code below on the event that you'd like it to execute -- for example, onClick, onLoad, etc.
ObjCombo1=document.forms[0].combo1; ObjCombo2=document.forms[0].combo2; viewname = "testvik"; //dbColumn("serverName","DbName", viewname,1,Combo1) keyVal=ObjCombo1.options[ ObjCombo1.selectedIndex].text; ObjCombo2.length = 0 dbLookup("http://127.0.0.1","R&D/testing.nsf", viewname , keyVal , 2, ObjCombo2 ) //Paste the below code on JS Header of the form... n=0; // This is for dblookup var dbkey = 0; // This is for dbcolumn /*--------------------------- Dbcolumn function start here -------------------*/ function dbColumn(server,path,view,column,Subject) { ObjCombo1=Subject //Put your first combo name //here to get dbcolumn result var pos=0; currURL = (document.location.href).toLowerCase(); if (trim(server) == "") { pos = currURL.indexOf('://'); if (pos < 0 ) // Put your server name here, the server name used here is basically for local machine or else not required. server = "http://127.0.0.1" else { pos += 3; pos = currURL.indexOf('/', pos); server = currURL.substring(0, pos) } } if( trim(path) == "" ) { if( pos > 0 ) { newPos = currURL.indexOf('.nsf',pos); if (newPos > 0) { path = currURL.substring(pos+1,newPos+4) } } } if( !isNaN(column) ) column -= 1; dbkey = column ; vurl = trim(server)+"/"+trim(path)+ "/"+view+"?Readviewentries" //checking whether browser is Mozila or Netscape if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.overrideMimeType('text/xml'); req.onreadystatechange = processReqChange_Col; req.open("GET", vurl , true); req.send(null); } //checking whether browser is IE else if (window.ActiveXObject) { req = new ActiveXObject ("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = processReqChange_Col; req.open("GET", vurl, true); req.send(); } } } /* Function used to check whether XML file loaded completely or not */ function processReqChange_Col() { if (req.readyState == 4) /*Only process if XML file is loaded completely:4="Complete" */ { if (req.status == 200) /*Only process if everything is ok*/ { response = req.responseXML.documentElement; populateColumn(response) } else { alert("There was a problem retrieving he XML data:n " + req.statusText); } } } /* Function used to extract value one by one from XML file */ function populateColumn(responseXML) { NodeList = responseXML.getElementsByTagName("viewentry") for (var k=0; k<NodeList.length; k+=1) { child = responseXML. getElementsByTagName('text')[k]. firstChild filterNode = responseXML.getElementsByTagName("viewentry") var filterItem = filterNode.item(k); posNumber = filterItem.getAttribute("position"); if (( child.nodeType == 3) && (posNumber.indexOf(".")==-1)) { NodeList1 = filterNode[ k].getElementsByTagName("entrydata") for (var m=0; m< NodeList1.length; m++) { if (dbkey == NodeList1[ m].attributes.getNamedItem ("columnnumber").value) { resultColXML[k] = trim(NodeList1 [m].getElementsByTagName("text") [0].childNodes[0].nodeValue ) } } } } var finalresult= new Array() var tmpstr=""; var sep=""; var Duplicateflag = " " ; // This string variable is used to get the duplicate values.. for (var p=0;p< resultColXML.length;p++) { if (resultColXML[ p] != '' && resultColXML[p] != null ) { if ( Duplicateflag.toUpperCase() != resultColXML[p].toUpperCase() ) // This is to get if the previous value was the same as the current one { tmpstr =tmpstr+sep+trim (resultColXML[p]) sep="#" } Duplicateflag= resultColXML[p]; } Duplicateflag = resultColXML[p]; } finalresult = tmpstr.split("#") writeInCombo(finalresult.sort() ,ObjCombo1) } /* Function used to trim string */ function trim(str) { return str.replace(/^s+/g, '').replace(/s+$/g, ''); } /*--------------------------- writing in combo function start here -------------------*/ function writeInCombo(data,fldCombo) { fldCombo.length=0 fldCombo.length +=1 fldCombo[fldCombo.length-1] .text = "--Select--" for(iCount=0;iCount < data.length;iCount++) { fldCombo.length +=1 strText=data[iCount] if (strText !=undefined && strText != null) { fldCombo[fldCombo.length- 1].text = trim(strText) } } }
Do you have comments on this tip? Let us know.
Related information from SearchDomino.com:
This tip was submitted to the SearchDomino.com tip library by member Vikram Solanki . Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.