Struggling with python in Base

Hello, I’m quite new to python scripting. I’m trying to write some macros in python for Base but I’m finding a lot of difficulties. I have a form for entering data into a table and when it saves the record it triggers a macro in which I want to populate other table with data from this form, but I can’t get a connection to the database. XSCRIPTCONTEXT.getDocument() doesn’t return the document and I don’t know how to do it. I’ve spent several days trying everything without luck. I’d appreciate any help.
Thank you

Then you should choose another field of activity. LibreOffice (and Base in particular) is extremely complicated even for experienced programmers.

This indicates bad database design. With good database design you would never store any duplicates.
XSCRIPTCONTEXT.getDocument() is one of the things that work differently in Base. WIth forms you should always resort to driven programming.
Macros impose many more problems than they are able to solve.

Thank you for the information. Maybe I could redesign the database so as not no duplicate data, but anyway, I need to manipulate the data entered in the form and write the results, so I definitely need to write into the database . I’ll try to think of alternative ways to accomplish it

Shooting into the dark: has two forms where subforms inherit data from parent forms.
When working with Base forms, you have to study all the possibilities of subforms and list boxes in combination with parameter queries. Subforms and listboxes can represent complex hierarchies of related record sets without writing a single line of macro code.
Tutorials and example databases: Base (View forum) • Apache OpenOffice Community Forum

the example is helpful and I’ll certainly use its principles, although it won’t solve all my problems. I’ll try writing some code outside Base to automate stuff.

Thank you

Nothing will ever solve all your problems with Base. The whole component is poorly maintained and did not change significantly since 2011 when the Sun corp. went down and 2 Base maintainers had to change their professional perspectives. I use Base since 12 years very productively with only a few lines of code. If this code would suddenly fail, I could redesign most of my forms (except one) within a few minutes, so they work without any code but with a few more clicks.
Good enough is better than never finished. And the worst database is still better than the best “spreadsheet solution”.

It totally depends on the application, client, and environment. I’ve facilitated a database kept in a word processor using mail merge. It wasn’t pretty but it was the client’s preferred option.
As for a form, one field per line, all fields for a record.