The Business Controls Caddy

Permalink Saying Goodbye to @DBLookups on the Web




This Monday, Sean "Phig" Burgess (see image on right) posted an article entitled "Using AJAX as a replacement for @DBLookups" that included some code that allowed him to replace the @DBLookup formula in a computed field with AJAX, allowing for a seamless field refresh without having to have the browser window unload. This was exactly the type example I had asked Julian Robichaux about a few weeks ago. In fact, Julian pointed me to Phig's posting at almost the same time I was looking at it. Needless to say I was quite excited. In his article, Phig said that his was a basic approach for one field that could easily be extended to multiple fields.

Needless to say this is what I did and I wanted to
post my extension of the code here for people to use and play with. It has not been through rigorous quality assurance yet (ok no QA yet), and I will post any changes as they come up (this means don't blast the code, just look at the objective:-)).

Design Goals

I have a Domino form with three combobox fields, which translate into "SELECT" objects in web browser. In addition, there are six other fields that capture address and contact information. The second combobox is only used if one of two values are selected from the eight available in the first box, and the choices need to be populated based on that selection. The third combobox is dependent on the choice of one specific value in the first combobox and the selection in the second combobox. The values of the other six fields are looked up and returned as one string that is parsed out to the other fields using formula language. The lookup key is based on certain business rules associated with the first three combobox fields.


So what I wanted to do was replace the @DBLookups for the keyword choices with AJAX (replacing the available options on the fly), as well as the lookup that returned the address/contact information.


Step One


I created a hidden field on the form containing the address information that stored all six values as a string, with the internal key being the field name that would receive the parsed data in the end, and with an ampersand as the delimiter.


Step Two


I created my agents to be called by AJAX. No need to post that basic code here, but this is the first time I have ever used the LotusScript "evaluate" to execute an @DBColumn to get the values for the second combobox field. Why the first time? Because I never had a need to before.


Step Three


I modified Phig's JavaScript code as follows (again ignore bad coding on my part at this time):


var xmlhttp=false;

if (!xmlhttp &&
typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}

function getContactPhone(username, objID, objID2) {
var objSchool =
  document.getElementById(objID2);
for (i = objSchool.length; i > 0; i--)  {
 objSchool.options[i] = null;
}
if (username !="Select Name")   {
var strUser=username.replace(" ", "+");
var strHTML
if (objID=="Some value") {strHTML=
    "http://db.nsf/GetAgent?OpenAgent;
} else if (objID=="Some other value") {

    strHTML= "http://db.nsf/GetSome?OpenAgent";
} else  if (objID=="something else") {

    strHTML="db.nsf/GetYetAnother?OpenAgent";
  }
xmlhttp.open("GET", strHTML);


xmlhttp.onreadystatechange = function() {
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    var strReturn=xmlhttp.responseText;
    var aString=strReturn.split("&")
    for (i = 1; i < aString.length; i++)  {
     var strText=aString[i];
     var strValue=aString[i];
     var myNewOption = new Option(strText,strValue);
     if (objID=="ValueA") {
      document.forms[0].ValueA.options[i] = myNewOption;
    } else if (objID=="ValueB") {
      for (i = 0; i < aString.length; i++)  {
       var iOf=aString[i].indexOf("=")
       var strField=aString[i].substring(0, iOf)
       var strValue=aString[i].substring(iOf+1, aString[i].length)
       var obj =
        document.getElementById(strField);
        obj.value = strValue;
      }
 } else {
 document.forms[0].ValueC.options[i] = myNewOption;
      }
}
}
}
xmlhttp.send(null);
}
}


Tying This Into IT Governance


You did not think you were getting away that easily did you? Very simply, one objective of a sound IT Governance Framework is that applications are designed to make life as easy, simple and intuitive as possible for the end users. This is one way to do it.


And For The .Net People Out There


I showed this solution to a person working on a .Net portal and he simply said that it was too bad they could not do the same thing with their portal applications. Well I am sure they could but they did not design their applications this way, so their users will suffer...


Disclaimers

  • I still need to test this over dial-up as that is how users will encounter the form in question.
  • I am still working on disabling the select objects until they are avaiable for use, but I am having some browser issues with that. But stay tuned...



Comments
06/29/2005 08:16:29 PM

Comment posted by Stan Rogers06/29/2005 08:06:04 PM
Homepage: http://stanrogers.blogspot.com


@DbColumn is, as far as I am concerned, THE reason to use Evaluate, especially when grabbing a list of top-level categories.


06/29/2005 09:18:30 PM

Comment posted by Julian Robichaux06/29/2005 09:11:17 PM
Homepage: http://www.nsftools.com


Excellent. I love it when people post their code.


- Julian


06/30/2005 09:43:28 AM

Comment posted by Sean Burgess06/30/2005 09:41:08 AM
Homepage: http://www.phigsaidwhat.com


Thanks for the plug. Next, I want to come up with a Javascript function that will do the same thing that @Word does to allow me to bring back a bunch of information in one generic call and then parse the information on the page.

Sean----


06/30/2005 11:14:30 AM

Comment posted by Ashish Sidapara06/30/2005 11:10:00 AM
Homepage: http://lono.blogspirit.com


Thanks for sharing. I did a similar thing sometime back ( using XMLDom ) & posted it on searchdomino. Next i found out that i was the winner of their tip contest which got me an iPod Mini.

http://searchdomino.techtarget.com/tipsHallOfFame/0,289489,sid4_cts853686_prz957090,00.html

cheers !!
Ashish


06/30/2005 07:37:29 PM

Comment posted by Richard Schwartz06/30/2005 07:10:20 PM
Homepage: http://www.rhs.com/poweroftheschwartz


@Sean: there's a split() function in JavaScript that you should look at.

-rich


07/08/2005 09:32:00 AM

Comment posted by Jeff Crossett07/08/2005 09:20:48 AM


You can also use a Domino view/form that is set to use a single category to give you XML for an AJAX call. The view columns need to each create a data node by open and close tags, and you will need a field that parses the query string to get your category, and finally to set your view to show only that single category.

Unfortunately, I could not find a way to use ?readviewentries and the single category function, or one might be able to use Dominos built in XML rendering.


05/18/2006 03:19:16 PM

Comment posted by 05/18/2006 03:12:30 PM



Add Your Comments



Email addresses provided are not made available on this site.





You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links


:angry: :-( :-p :lips: :laugh: :-o :rolleyes: :huh: :-D :grin: :cool: :cry: :-) :-\ ;-) :-x :emb:






Remember me    

Add Manual Trackback
Please enter the details of the trackback post. Your trackback will not appear on the site until it has been verified. This may take up to 10 minutes.

Site Name

Permanent URL of TrackBack Post

Title of Post ( If Any )

Excerpt of Post ( Max 250 Chars )



Search
Google
Sponsored Ads
My Other Blog

Fighting Fud

Fear, Uncertainty and Doubt (FUD) are too often used as marketing tools. And too many mainstream publications are citing reports that have no validity. So if you know anybody who is citing these publications and reports to make business decisions, please point them to one or more of these links. You can also point them to the "Fighting FUD" index of stories and/or add the "Fighting FUD" graphic link to your web site.



flag icon graphic Microsoft Tries To Feed Up More FUD, Again

flag icon graphic Lies, Damn Lies, and Radica...oops I Mean Statistics

flag icon graphic On Forbes, Foolishness and FUD

flag icon graphic When Technical Magazines Fuel FUD


Fighting FUD Blogroll
Tom "Duffbert" Duff
Chris Linfoot
Matt White
Joe Litton
Jeff Crossett
Gerco Wolfswinkel
Chris Whisonant
Gregg Eldred
Richard Schwatrz

Leaderboard By Category

About Me
About the Blog
Accounting Software
Admin2005
Articles
Auditing Standards
Best Practices
Best Practices - Coding
Blogging Risks
Blogging Templates
Blogsphere
Book Downloads
Book Reviews
Bookstore
Business Continuity
Business Continuity/Disa...
Business Controls
Business Controls Humor
Business Process Re-Engi...
Caddyshack
Case Studies
Collaboration Tools
College Football
College Hoops
Commentary
Community News
Compliance
Compliance Tools
Compliance Tools - Lotus...
Conference Presentations
Control Frameworks
Control Self Assessment ...
Copyright, Fair Use and ...
Corporate Governance
Data Protection
Daylight Savings Time
Dimensions of Leadership
Disaster Recovery
E-Commerce
E-Mail Compliance
E-Mail Etiquette
Employee Policies
Ethics
Exposure Drafts
Eye on Sports Media
Fighting FUD
Fraud Prevention
General
Going Green
Golf
Governance Cup
Government Compliance
HIPAA
Humour/Satire
IBM Pensions
IM Controls
Internet Safety
Interviews
Ireland 2007
IS Governance
IS Governance At Home
IT Audit Tools
IT Governance
IT Governance Insight
ITIL
Just for Fun
Licensing
Live Blogging Tools
Lotus AdvisorLive
Lotus Notes 8
Lotus Quickr
Lotusphere 2005
Lotusphere 2006
Lotusphere 2007
Lotusphere 2008
Lotusphere 2009
Movie Reviews
News Links
Newspaper Columns
Niagara Basketball
None
Notes 8 Beta
Notes/Domino Administrat...
Notes/Domino Development
Notes/Domino Mail
Notes/Domino Security
Observations
Outsourcing
Patent Issues
Presentations
Press Releases
Privacy
Procurement Controls
Product Advocacy
Professional Development
Records Retention
Reflections
Risk Assessment
Sarbanes-Oxley
Sarbanes-Oxley Tools
Secure Messaging
Security Awareness
Security Controls
Site Update
Smoking Kills
Social Engineering
Social Software
Social Software Risks
Software Development Con...
Software Tools
Spreadsheet Controls
Telecommuting Risks
The Disposable Society
Training Series
Travel Tips/Observations
Trivia
TV/Radio Sports
Understanding COBIT
User Education
User Interface
Vocabulary
Way Off Topic
WebSphere
XBRL
XML Feeds