Someone else may have mentioned this already, but… I’ve set up a global value list utilizing related database values, displayed as a combobox. But when I try to leave designer mode and view the form, Servoy does not display the form. The only way I can view it is to exit designer mode and view a different form, and then switch back to the form with the value list via the Windows menu. This is Servoy 2.01 on Mac OS X 10.3.3. -pw
This is fixed in Servoy 2.02
Jan Blok:
This is fixed in Servoy 2.02
Great, thanks. When initially displayed, the field with the comboBox does not display any of the values in the list - the field is blank. A list value is displayed only when manually selected from the list. Is there a way have Servoy automatically select and display the first value in the list? -pw
"pweil:
Is there a way have Servoy automatically select and display the first value in the list?
Yes fill the dataprovider with the wanted value on creation of record.
Jan Blok:
"pweil:
Is there a way have Servoy automatically select and display the first value in the list?Yes fill the dataprovider with the wanted value on creation of record.
Since this is a related value list, it appears as though I can’t use getValueListItems. How can I assign the first item of a related value list to the dataprovider? thanks, -Peter
during creation of a orderdetail you can do something like:
orders_to_orderdetails.quantity = 1
assumming there is a combobox on the related quantity dataprovider , if ‘1’ is in the valuelist it will select this value
Jan Blok:
during creation of a orderdetail you can do something like:
orders_to_orderdetails.quantity = 1
assumming there is a combobox on the related quantity dataprovider , if ‘1’ is in the valuelist it will select this value
I don’t think this approach is going to work for us, so perhaps I ought to explain what this is for. We have multiple purchasing “agents” who are associated with more than one customer account, and we have set up the neccessary N-M table(s). When our data entry person creates an invoice, he enters the agentID, which triggers a lookup of agentName and account(s). If the agent belongs to more than one account, I want to make it easy at the GUI level for the data entry person to select the appropriate account. Presenting a list to select from in some fashion would seem to make sense. But if the agent is associated to only one account (as some agents are), selecting from a list shouldn’t be necessary, so we would like to have that account displayed and entered by default.
I hope this make sense. Any suggestions on ways to do this will be greatly appreciated. -Peter
What you want is fairly easy:
have the user key the agent_id (or use a valuelist) into a global. Relate that global to your n-m file. Make a valuelist based on that relation to the customer ids. Attach that valuelist to customerid field in invoices and also set the related customerid (through the relation you just created) to auto enter. That way the value is prefilled as soon as agentid is chosen.
jaleman:
have the user key the agent_id (or use a valuelist) into a global. Relate that global to your n-m file. Make a valuelist based on that relation to the customer ids. Attach that valuelist to customerid field in invoices and also set the related customerid (through the relation you just created) to auto enter. That way the value is prefilled as soon as agentid is chosen.
Thanks for this suggestion, Jan. We couldn’t quite do this, though, because the data provider for the value list in this form is global, so auto enter is not an option here (we want to keep the data enterer from modifying the database directly, and only after all data is submitted and validated). We did come up with an alternative using methods. It still lacks error handling, but it does present a nice list to select from in the select dialog box:
controller.find()
initials = globals.AgentInitials
controller.search(true, false)
//put the results of the account_id lookup into an array
var accountArray=databaseManager.getFoundSetDataProviderAsArray(agents_to_agents_accounts, 'account_id')
//throw fit here regarding no accounts
//this point on, accounts > 0
//loop to build query mapping account_id to account_name for each item in array
var sql = "select account_name from accounts where account_id=" + accountArray[0]
for(x = 1; x < accountArray.length; x ++) {
sql += " or account_id=" + accountArray[x]
}
//do the query, place results in an array, and set account field to selected item
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), sql, null, accountArray.length)
var selectedAccount=dataset.getColumnAsArray(1)
globals.AgentAccount=plugins.dialogs.showSelectDialog( 'Accounts', 'Select an Account', dataset.getColumnAsArray(1) );
[/quote]