Are you populating names in the FORM_OnAfterTransaction function? You'll find that even though the list box shows a value, it's not actually "selected". So what you need to do is set the select form field to the value of the data that came back in the transaction and then call the routine to get the display value for the selected value. For example, here is what I did for state:
//Select the state in the state list box. lawForm.setFormValue("select35",lawForm.getDataValue("VDR-STATE"));
// Put the state name in the textbox next to the state. lawForm.setFormValue("text85",getSelectedListboxValue("_l623"));
Incidentally, I placed the getSelectedListboxValue in a global functions include file so I can just call it with one line rather than coding that loop everywhere. Here is the function:
function getSelectedListboxValue(lb) { /* This function returns the display value of the selected item in a listbox. Example call: var myselectedvalue = getSelectedListboxValue("_l623"); */ var myDisplayValue = ''; // This is the value that will be returned to the caller. var myListbox = lawForm.getElement(lb); // This gets a reference to the list box. // Loop through all the items in the list box until we find the one that was selected. for (var i=1; i < myListbox.childNodes.length; i++) { if (myListbox.childNodes.selected == true) { // Test to see if the item is selected. myDisplayValue = myListbox.childNodes.attributes['disp'].nodeValue; // Get the display value of the selected item. break; //This breaks out of the for loop. No need to continue checking items after we've found the selected item. } }
return myDisplayValue; }
Regarding your hidden field not working, it's difficult to determine the issue without actually having your full program. In my case I didn't even change the field name; I just added tp="Hidden" to the field. Below is what I did for the state field. Make sure the "nbr" and "nm" match the Infor generated values for those fields.
fld al="left" blankzero="1" col="42" ed="upper" height="1" id="text11" label="State or Province:" nbr="_f29" nm="VDR-STATE-PROV" par="TF0-0" row="8" sz="2" tp="Hidden"/
Regarding the read only attribute, listboxes don't have that property. Try lawForm.getElement("_l183").disabled=true; (use your field ID).
Click on Edit ---> Tab Order. Is the text box the first field in the list? If so, that's where your cursor will go. Set your select box as the first field in the list and you don't need to use positioninfieldbyid.
And apparently in Infor v10 the list box is a true list box rather than a combo box. In version 9 you had the option of typing a new value into the combo box but not in version 10. You can only type in an existing item.