The situation:
Servoy Developer
Version R2 2.2.4-build 336
Java version 1.5.0_06-b05 (Windows XP)
Have a form (product info) with a tabpanel showing product items (all but one field uneditable)
Relation works, regular and scripted newrecords work.
Have a product creation form (based on same relationship as tabpanel) for these product items as we don’t want product items to ever be deleted or changed (except for a selected field or two). This form is a combo of text fields( no dataprovider) and a global field combobox using a value list. This form has an ADD button that runs the following method:
elements.pi_new_baseprice.selectAll()
fsmv_pi_new_baseprice = elements.pi_new_baseprice.getSelectedText()
elements.pi_new_iunit.selectAll()
fsmv_pi_new_iunit = elements.pi_new_iunit.getSelectedText()
fsmv_pi_new_dunit = globals.fs_gv_pi_dunit
// All above just grabs the "dummy" field info
if ( !fsmv_pi_new_dunit) {
//show dialog
var thePressedButton = plugins.dialogs.showWarningDialog('Warning', 'Please enter a display unit','OK');
return;
}
if (isNaN(fsmv_pi_new_baseprice) || parseInt(fsmv_pi_new_iunit)!=fsmv_pi_new_iunit-0) {
//show dialog
var thePressedButton = plugins.dialogs.showWarningDialog('Warning', 'Base Price must be number (can include decimal), Display As must be an integer (whole number) - please check and try again','OK');
return;
}
var fsmv_pi_new = plugins.dialogs.showQuestionDialog( 'Add Product Item', 'Are you sure? This will use a product item ID # (ie, CATNO-ID)', 'Yes', 'No')
// Dialogs above for validation warnings and ARE YOU SURE?
if (fsmv_pi_new == 'Yes') {
// CREATE NEW PRODUCT ITEM, SET as needed
forms.fs_product.fs_product_to_fs_productitems.newRecord(true)
fs_productid = forms.fs_product_setup.fs_product_to_fs_product.fs_productid
fsmv_pi_pcount = forms.fs_product_setup.fs_productitemcount + 1
fsmv_pi_pcount = forms.fs_product_setup.fs_productitemcount
fs_productitemscatno = forms.fs_product_setup.fs_productcatno + '-' + fsmv_pi_pcount
fs_productitemsstatus = "N"
fs_productitemsdunit = fsmv_pi_new_dunit
fs_productitemsdint = fsmv_pi_new_iunit
fs_productitemsbaseprice = fsmv_pi_new_baseprice
fs_productitemstype = "M"
}
If I run this from another relation in the same tab panel, all works well…however
Problem:
Trying to use the create form in a showformindialog()
If using the creation form in a dialog, upon clicking ADD, another record is added BUT the data is saved back to the LAST SELECTED productitem rather than the new record - ie, new record is blank, previously selected record (if any, problem only occurs where related record already exists AND tabpanel with related records shows the existing record being selected)
Then, of course, the new record fails due to required fields not being present.
Finally, after clicking add and closing the dialog, the newrecord IS selected - but empty of data, while previous record contains the data intended for the new data.
Again, all works perfectly IF using different two tabpanels, or a single tab panel with the two forms on different tabs. With showformindialog, however, it only works IF the tabpanel showing the related records is not showing (ie, two-tab panel, non-related tab showing)
So, if the tabpanel is based on the same relationship as the showformindialog, the selected record STAYS as the tabpanel has selected rather than being overridden by the showformindialog’s form newrecord command.
Bug?
Thanks for any info! I can make it work another way, but took me over two hours to figure out it wasn’t something I was doing that exhibited the behavior.
Nolan M.
FSCI