popup menu question/help

Hi,
I am trying to return the display value from a popup menu as a argument
I have the following code so far, I know there is probally a simple solution but I am pulling my hair out :evil:

var vRecordId = 1
var vQuery = 'SELECT sales_rep.full_name AS sales_rep_full_name, sales_rep.rep_status AS sales_rep_rep_status FROM sales_rep sales_rep WHERE rep_status = ?'
var args = new Array();
args[0] = vRecordId //or  new Date()

var vServer = controller.getServerName();
var vDataset = databaseManager.getDataSetByQuery(vServer, vQuery, args, -1);
var vDataArray = vDataset.getColumnAsArray(1); //puts the contents from a column of the dataset into an array

//build menu
var menu = new Array
for ( var i = 0 ; i < vDataArray.length ; i++ ) {
    
	
	menu[i] = plugins.popupmenu.createMenuItem(vDataArray[i],popMenuActions,null)
		
}

//create arguments for the method calls
var x = 0
while (menu[x])
{
   menu[x].setMethodArguments(x,elemName)
   x ++
}

var elem = elements[application.getMethodTriggerElementName()]
if (elem != null)
{
	plugins.popupmenu.showPopupMenu(elem, menu);

}
}

Hi Phil,

I found 2 things in your code:

var menu = new Array
```That should be:

var menu = new Array();


And the real culprit:

menu.setMethodArguments(x,elemName)

menu.setMethodArguments([x,elemName])

Your arguments should be passed in 1 Array.

I also noticed the extra curly bracket at the end of your code but I assume that is the one from the function (method).

Hope this helps.