Hi Team!
In Web DBKit, I have a SinglePage with search listbox and textfields. I create a new record with the New button, and I want to pre-fill some of the fields, e.g. admin user, or date requested, or log (that sort of thing). Where is the correct place to set these values?
Is it SavingRow? I tried setting values to the row Variant in SavingRow but it seems to be the selected listbox row, not the newly created record.
I would prefer to do that within the pressed-event of the new button.
OK got it.
The solution is, make the New and Edit buttons normal WebButtons and then do what I need before and after I call the DBKit Connector methods as below.
I learned it’s important to set and get the control values rather than try and edit a rowset.
Also I needed to handle the button captions and field focus, and refetch the listbox contents at the end of the edit event to show in the ListBox
Also the Edit button does editing and saving so needed to be mindful of that.
New Button Pressed Event
System.DebugLog("New button pressed")
// set the defaults for new alerts
var date as DateTime = DateTime.now
var now as String = date.SQLDateTime
AlertConnector.NewRow
CreatedField.text = now
RequestedField.text = now
RegionalCheckbox.value = true
NameField.SetFocus
EditButton.caption = "Done"
Edit Button Pressed Event
var description as String = NameField.text + " is creating an alert for a " + TypeField.text + " in " + SuburbField.text
DescriptionField.text = description
// DBKit does its stuff
AlertConnector.EditRow
// only refresh after the edit is completed
if me.Caption = "Done" then
me.caption = "Edit"
SearchForAlerts
else
me.caption = "Done"
end
Hope this helps the next person.
1 Like