Populate a listbox from XUI dialog

David Long talks about using Application.openDocument Last Updated: 2006-11-30

I needed to populate a listbox in my xui dialog with data from the document I am working from during the dialog load process.

I created an init function in a *.js file but could not get a handle for the xui dialog until it had been fully realized. By setting the "xmlDoc" variable to the name of the document I am opening (xmlDoc = Application.openDocument) I get the handle.

var appDocPath = Acl.eval("doc_type_dir"); var epicStart = appDocPath.search(/epic/i); var SelectPrecondpath = appDocPath.slice(0, epicStart+5) + "dialogs\\SelectPrecond.xml"; var xmlDoc = Application.openDocument(SelectPrecondpath,(0x0001)); var SelectPrecondDialog = Application.createDialogFromFile(SelectPrecondpath); var doc = Application.activeDocument; var document = Application.activeDocument; SelectPrecondDialog.show; function SelectInit {  var statePreCond = document.getElementsByTagName("statemanipulation"); for (var i = 0; i < statePreCond.length; i++) {     if (statePreCond.item(i).firstChild.getAttribute("description") == "pre-condition") {       // combo box I wish to populate cmbNode = xmlDoc.getElementById("cbxPreCond"); listNode = xmlDoc.createElement("listitem"); cmbNode.appendChild(listNode); listNode.setAttribute("label", statePreCond.item(i).firstChild.getAttribute("name")); }  }  }