Record changes not being saved.

I am using Servoy 2.0.3 Developer on a PC running WindowsXP.

I have a Company Details form, that displays amongst other things a related contacts portal.

I have a create ‘New Contact’ button that creates a new related contact record, and then takes the user to that related record using a ‘Contact Details’ form ready for editing. (see ‘New Contact’ code below).

I then edit the fields on that form, with Name and address etc.

If I navigate around my solution, and come back to this newly created contact record, everything is OK, the edited details are present.

However, if I look at the record on another PC, or exit Servoy and go back into the solution and navigate to the newly created record, the edited details are not there, the record has reverted back to the original record creation details. In other words, the changes have not been recorded.

The ‘New Contact’ code:

var thePressedButton = plugins.dialogs.showQuestionDialog( 'Question',  'Are you sure you want to create a new Company Contact?',  'OK',  'Cancel');
if ( thePressedButton == "Cancel" )
{
	return
}
else
{
var theCompany_ID = companyid
var theSGB_Branch_Nbr = sgb_branch_nbr
forms.BranchCustomerContactDetails.controller.newRecord()
forms.BranchCustomerContactDetails.company_id = theCompany_ID
forms.BranchCustomerContactDetails.contact_title = "***Title***"
forms.BranchCustomerContactDetails.contact_first = "***First Name***"
forms.BranchCustomerContactDetails.contact_last = "***Last Name***"
forms.BranchCustomerContactDetails.contact_mobile ="**Mobile**"
forms.BranchCustomerContactDetails.contact_jobtitle ="***Job Title***"
forms.BranchCustomerContactDetails.company_name = "**Company Name**"
forms.BranchCustomerContactDetails.contact_office_address1 = "**Address1**"
forms.BranchCustomerContactDetails.contact_office_address2 = "**Address2**"
forms.BranchCustomerContactDetails.contact_office_address3 = "**Address3**"
forms.BranchCustomerContactDetails.contact_office_town = "**Town**"
forms.BranchCustomerContactDetails.contact_office_county = "**County**"
forms.BranchCustomerContactDetails.contact_office_postcode = "**Postcode**"
forms.BranchCustomerContactDetails.contact_office_country = "**Country**"
forms.BranchCustomerContactDetails.contact_office_tel = "***Telephone***"
forms.BranchCustomerContactDetails.contact_office_fax = "***Fax***"
forms.BranchCustomerContactDetails.sgb_branch_nbr = theSGB_Branch_Nbr
databaseManager.refreshRecordFromDatabase(companies_to_contacts, 1)
forms.BranchCustomerContactDetails.controller.show()
}

The company details form:

The contact details form following ‘New Contact’ and before editing:

The contact details form post edit:

The company details form post edit showing the record in the portal:

The company details form following Servoy exit and re-entry, showing record is now back to original state:

why are you doing there a:

databaseManager.refreshRecordFromDatabase(companies_to_contacts, 1)

call?

that doesn’t make any sense i my eyes.
Why are you creating a related record directly in form and not through the related foundset itself??

It seems that you don’t get in edit mode again when you chaning the record. Is there an E in the status bar when you are changing the fields?

If you start the developer with -DSTACKTRACE=TRUE and you change the record then click on the form (not in a field but in on the gray area) do you see an insert generated?

1 I’m doing the database refresh in an attempt to get the record saved to try to overcome the problem.
2 No real reason for creating the related record from the form, it just evolved that way.
3 I do get an ‘E’ in the staus bar when I edit the record.
4 How do I start Developer with -DSTACKTRACE=TRUE, where do I put this code? In the solution startup script?

I have just tried creating the related record by using:

companies_to_contacts.newRecord()

The results were the same, except that when viewing the related record after Servoy exit and re-entry (Image 5 in original post) all the fields in the record are now completely blank!

I should also point out that the repository is a sybase db, and the data file tables are mysql.

1> that won’t fix it at all, if you really want to save it you should call controller.saveData()

4> in the servoy_developer.bat you have this:

javaw -jar servoy_developer.jar

make it this way:
java -DSTACKTRACE=TRUE -jar servoy_developer.jar

or start it up through a command prompt by typing the above line when you are in youre servoy dir.

What kind of database you use don’t have any effect.

If you could send me youre solution (with sample data) or an example solution that demonstrates this behaviour then i can look at this over here.

just for youre information if you really want to refresh youre new record
then you shouldn’t do this:

databaseManager.refreshRecordFromDatabase(companies_to_contacts, 1)

but this

databaseManager.refreshRecordFromDatabase(companies_to_contacts, controller.recordIndex)

becasue then you refresh the current selected record (youre new record)