How do I get a value for the computed field which perform a dblookup from view onload of a new document in web environment? I tried to put doc.Refresh.click() in the onLoad event and I got the value but it keeps looping. Appreciate if someone can advice, thanks.
Subject: Refresh computed field onload event
Try this with the following code. Using Readviewentry
function dbLookup(server,path,view,key,column){
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
var pos=0;
currURL = (document.location.href).toLowerCase();
if (trim(server) == "")
{
pos = currURL.indexOf('://');
if (pos < 0 )
server = ""
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;
vurl = trim(server)+"/"+trim(path)+"/"+view+"?readviewentries&login=1&count=9999";
xmlDoc.load(vurl);
nodes = xmlDoc.documentElement.childNodes;
temp = new Array(nodes.length);
var j = 0;
for (var i = 0; i < nodes.length; i++)
{
if(nodes.item(i).childNodes.item(0).text==key)
{
temp[j] = nodes.item(i).childNodes.item(column).text;
j++;
}
}
var results = ""
for (var i = 0; i < j; i++)
{
if (i==0)
{
results = temp[i];
}
else
{
results = results + ", " + temp[i];
}
}
return(results);
}
Call the function by passing the values for server,path,view,key and column. Call it onload of the form.