Here’s the code for my agent:--------------------------------------------------------------------------
Sub Initialize
Dim s As New NotesSession
Dim doc As NotesDocument
Dim searchDoc As NotesDocument
Dim db As NotesDatabase
Dim view As NotesView
Dim result As String
Set db = s.currentdatabase
Set doc = s.DocumentContext
key = doc.Query_string(0)
Set view = db.GetView("(ProfilesbyUnique)")
Call view.Refresh
For i = 1 To view.EntryCount
Set searchDoc = view.getNthDocument(i)
If searchDoc.form = "Company" Then
If searchDoc.Unique = key Then
result = searchDoc.Number(0)
Exit For
End If
End If
Next
Print "Content-type: text/xml"
Print "<results>"
Print "<number>"+result+"</number>"
Print "</results>"
End Sub
The problem is the agent seems to not print anything since on the browser the response xml is null.
Is there something my tired eyes are missing in this?
Here’s my Javascript on the browser-side.
//calls server and processes result
function getUnique(key, objID) {
obj = document.getElementById(objID);
xmlhttp.open(“GET”, “/form.nsf/DBLookup?OpenAgent&key=” + key);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var xmlDoc = xmlhttp.responseXML;
updateDocument( xmlDoc );
}
else {
alert(xmlhttp.status);
}
}
xmlhttp.send(null);
}
//updates form
function updateDocument( xmlDoc ) {
var data = xmlDoc.getElementsByTagName( ‘result’ );
obj.value = getElementValue( data, “number” );
}
//reads the xml response
function getElementValue( xmlData, elementName ) {
var childElement = xmlData[0].getElementsByTagName( elementName )[0].firstChild;
if( childElement ) {
return childElement.nodeValue;
}
return “”;
}