Hi all,
This is an extension of my previous post about building global procedures and dynamically filling in data. Right now, I’ve got most of it working, but I’m having a problem getting the final piece to fit. Here’s a summary…
I have many places in my system where the user can provide data into fields through way of comboboxes. If the data they want isn’t in the valuelist attached to the combobox, they can type it into the field, and the system will sense that the data is not in the table underlying the valuelist and ask if the user wants to add it. I can code this for every field doing this, but I want to create a global procedure and fill in the necessary data dynamically.
Right now, if the user types in new data, when they hit enter or tab out of the field, an onDataChange event is triggered. Within that code, I can determine what form I’m in, what field I’m in, the valuelist attached to the field, and table behind the valuelist, and the field in the table that’s the data provider for the valuelist. I can see valid data in all of these fields from within the debugger.
Basically, I do a search to see if newValue is in the table, and if not, I can add it. As a hard coded example, this works fine for constructing a search field…
dcfoundset.subject = newValue
dcfoundset is a foundset that I create using the table underlying the valuelist. “subject” needs to be replaced with a variable that can be filled in with the value of the field from the table, dynamically. I know what field it is from
mydataprovider = solutionModel.getValueList(myvlist).getReturnDataProviderIds()
mydataprovider should be an array filled with the dataproviders for this value list (for these tables there is only one dataprovider for the valuelist). What I haven’t been able to figure out is how to use that to specify the dataprovider for the search.
I’ve tried dcfoundset.mydataprovider[0] = newValue and
dcfoundset[mydataprovider[0]] = newValue
Both generate warnings and runtime errors.
So, I’m kind of unclear at this point what I’m doing wrong. I suspect it’s probably just a syntax issue, but there could be another problem I’m not seeing.
Here’s the rest of the code…
var myform = event.getFormName()
var myfield = event.getElementName()
var myvlist = solutionModel.getForm(myform).getField(myfield).valuelist.name
var myvlisttable = solutionModel.getValueList(myvlist).tableName
var mydataprovider = new Array()
mydataprovider = [solutionModel.getValueList(myvlist).getReturnDataProviderIds()]
/** @type {JSFoundsetdb:/workingartist/tblartworksubject} */
var dcfoundset = databaseManager.getFoundSet(‘workingartist’,myvlisttable)
if (dcfoundset.find()) {
dcfoundset[mydataprovider[0]] = newValue
var result = dcfoundset.search()
if (result == 0) {
var dlgresult = globals.DIALOGS.showWarningDialog(‘WorkingArtist Message’,‘This is not in the list. Would you like to add it?’,‘yes’,‘no’)
blah blah blah
Any thoughts you might have would be appreciated.
Thanks and have a good day.
Ron