ChristianNissen

What table for "New Record/Request"?

Discussion created by ChristianNissen on Jun 9, 2016
Latest reply on Jun 9, 2016 by ChristianNissen

FM´s lack of rationality and clear documentation drives me mad.

 

Why on earth is there NOT a variable to define WHAT table I would like to make a new blank post/record/row in?

 

It seems - correct me if I am wrong (because the documentation does not say) - that the table in question is the table selected in the layout I am operating when doing a "New Record/Request" script step?

 

However that layout takes data from three different tables and shows it in the layout...

 

Debits, projects and invoices are the tables. They are joined with debits::projectnumber = projects::projectnumber and debits::invoicenumber = invoices::invoicenumber

 

Projects is the choosen table for the view. I start with projects that has outstanding not invoiced debit posts. In the table view I can see a list of projects with debits that is not invoiced. I choose one project and change view to forms.

 

All data is collected from debits of the choosen project and the project it self. The form is filled and the invoicedata (like sums) are calculated, only the invoice number is left blank at this stage.

 

When the data is checked, and I am ready to take out an autoincremented  invoicenumber, (this serialnumber must be a continous numberseries according to law, with no numbers missing, even if I decide to finish the invoice at a later time) there is a button in a bottom pane that activates a script, that should:

1/ Make a blank record/post/row in the invoices table

2/ Set the invoices::invoicenumber to the next serial increment (the field is numeric and autoincrement in the database)

3/ Read that number into a variable: $invoicenr = invoices::invoicenumber

4/ Take that variable and read it into all the debitposts in this selection: debits::invoicenumber = $invoicenunr

5/ Set various other fields of the new invoices record (like from the calculated sums), which I skip in this discussion

6/ Save the new invoices record

7/ Save all the debits records (can be from one to maybe twenty) with the changed value of debits:invoicenumber

8/ Show the now finalized invoice (with the incremented correct invoicenumber) ready to be printed out.

 

I fail already at point 1/ with the new record in invoices...

Trying to fool FM with: 

 

1 - Set Field [invoices::invoicenumber]  *something needs to be pointing away from projects table to the invoice table? Right? Perhaps something else should be used?

2 - New Record/Request   *seems to be making a new projects record, NOT a new invoices...how much better it would be with "New record [invoices]"? end of doubts....

3- Set Next Serial Value [invoices::invoicenumber]   * doesn´t matter if I use this row or not, or rely only on the database parameter "serial incerment" which by the way is set to "Autoincrement on creation of record".

 

I use the "debug" and "dataviewer" to check the progress of invoices::invoice (and other data)

 

After step 1 its the last accessed invoice post for the selected project in this case invoices::invocenumber is 10006 (numerical)

After step 2 its NULL

After step 3 its still NULL

 

I have no clue....?

Outcomes