Update one table with contents from another table

I’m new to servoy, and javascript, and have spent a long time looking at posts related to this subject, but can’t seem to find the answer I’m looking for. I think it’s a fabulous application but I’m still learning all the ins and outs.

I have a solution that involves a personnel table, proposal table and a grants table. I have tabs set up that will display a personnel record and the related proposals and grants for that record. In the proposals form I have a button (called approved) that when clicked on, I would like to create a method that takes the contents of the proposal table and updates the grants table with all the similar fields. I have relations setup between proposals, grants and personnel. I’ve tried the fsUpdater method, but it doesn’t know about the grants fields, and I’ve tried the getDataSetByQuery, to retrieve the field contents, but I don’t see a function to write the query back to the grants table.

After posting this in the programming forum, I got the following reply, but when I tried it, I got a new grants record, but the fields were all null

From the proposals table you can set fields of the related record in the grants table using:

Syntax:
relationship_name.field_name = field_name

Example:
proposals_to_grants.company_name = company_name

The method I tried was :

forms.grants.controller.newRecord()
proposals_to_grants.account_manager = manager
proposals_to_grants.lastname = pi_lastname

where account_manager is in the grants table and manager is in the proposals table. I even added in the forms.grants in front of the proposals syntax, but the same result - nulls.

Any help with this would be greatly appreciated. Until I sort out what I’m doing wrong, I’m dead in the water.

Thanks
Graham

Graham,

Use this instead:

forms.grants.controller.newRecord()
forms.grants.account_manager = manager
forms.grants.lastname = pi_lastname

Hi again Greg,
Thanks for sticking with the newbie. I’m totally confused now. I tried putting your last suggestion in the method, but now I’m getting a popup message that says could not perform form method ‘null’, with no details.

I may be doing something wrong with my forms. I have a tab that will list the proposals in a list (much like crm), when I click on the button to display the complete form, It pops up the form with the approval button on it (proposals). All the fields in that form are filled in from the proposals table, yet when I hit the approved button I get the above message.

Sorry to be such a pain.
Graham

Ok,
My thanks to Greg - If I had a brain, it would definitely be lonely…

I can now update the database fields from the proposals field, and it actually works using the forms.grants.account_manager = manager method. The null form is coming from some other mistake I made.

Thanks for the help - I truly do appreciate it.

Graham