This tip works if you have an application that required an address, city, state and zip code. If you ask for the zip code first and pass it to a Web service (as shown below), it will bring back the city and state, thus allowing you to populate that information for the user.
'Put this in the Existing event of the Zip code field or where ever you want to trigger it from Dim s As New notessession Dim ws As New NotesUIWorkspace Dim db As NotesDatabase Dim view As NotesView Dim uidoc As NotesUIDocument Dim doc As NotesDocument Dim sourceFile As Variant Dim showReturn As String Dim strGetZip As String Set db = s.CurrentDatabase Set uidoc = ws.CurrentDocument Set doc = uidoc.Document strGetZip = doc.Zip(0) showReturn = getCityState(strGetZip) Function getCityState(strZip1 As String) As Variant Dim s As New NotesSession Dim db As NotesDatabase Dim dbLK As NotesDatabase Dim viewLK As NotesView Dim docLK As NotesDocument Dim xmlapp As Variant Dim sReturn1 As Variant Dim strState As String Set db = s.CurrentDatabase sourceFile="http://www.webservicex.net/ uszip.asmx/GetInfoByZIP?USZip=" + strZip1 Set xmlapp = CreateObject("Microsoft.XMLDOM") xmlapp.async = False xmlapp.load(sourceFile) doc.City = ElementsByTagName2(xmlapp,"CITY") strState = ElementsByTagName2(xmlapp,"STATE") Set dbLK = s.GetDatabase(db.Server,"LookupGLV.nsf") Set viewLK = dbLK.GetView ("LKbyStates5" ) Set docLK = viewLK.GetDocumentByKey (strState) doc.State = docLK.spState(0) End Function Function ElementsByTagName2(xmlapp,Tag As String)As String On Error Goto errHandle Dim XMLList() As String Dim x As Variant Dim i As Integer Set x = xmlapp.getElementsByTagName(Tag) Redim XMLList(1 To x.length) For i = 1 To x.length XMLList(i)=(x.item(i-1).text) Next ElementsByTagName2 = XMLList(1) Exit Function errHandle: ElementsByTagName2 = 0 Resume Next End Function
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member Michael Marcavage. Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Notes/Domino tip or code to share? Submit it to our bimonthly tip contest and you could win a prize and a spot in our Hall of Fame.