I learned a valuable lesson yesterday. I declared a Javascript variable called myarray and wanted to assign a list generated from a DbLookup. The good news is that this works 99%. There is just 1 small exception. If the DbLookup only returns 1 value, it then passes that value as a string and not an array, even if you force it to be an array. See below example of how to get around this.
// Initiate the DB Lookup and pass it to the JS Variable
var mydb = new Array(database.getServer(),database.getFilePath());
var myarray = @DbLookup(mydb, “ViewAliasName”, “key”, 2);
// Make sure a value was returned, then make sure it’s an array
if(myarray == undefined)
{
return false;
}
else if(myarray[0] == undefined)
{
var myarray = new Array( myarray );
}