Hi,
my purpose is to create a report that has:
-info such as client name, date, description…
-1 or more articles (each article has a code, a name and a cost)
I have 2 table, one for the “Report” and one for the “Articles”. In the “Report” table there is a relation column that link all the articles with the corrispondent report through the expected_report_number (calcoleted by latest report number + 1).
I create a screen based on “Report” table with a collection list where there is a button to add new report.
In the report form screen I added a collection list where I can see all the article related with this report I’m creating and through the “add” button I can add a new article if I need.
The problem is that if I’m creating a new report (for ex report 5), I add an article for this report (article will be related to report 5), and than I cancel the report form beacuse I don’t need anymore, the next time I want to create a new report I will found that article that I created before in the new form (form for the report 5 that last time I cencelled).
I was thinking to add an action to the first “add” button: before starting when I open the report form I add an action that delete all the old Article row that aren’t linked to a report. But the “add” button for the report doesn’t allow me to delete row in article table (only report).
Sounds like you need to approach it a bit different:
On entry to the form, set a column in your user profiles to have a unique ID value.
Use that unique ID value to add to the Articles table, served as the “Report ID”.
Submit that ID to your Report table once you’re doing adding other info.
By that, you’re not relying on the report number anymore, which sounds like it was causing problems. Then combine that with your idea here on entry to the form.
I partially solved the problem: using unique ID value I don’t see past articles created in report that has been deleted.
But this “ghost” articles that aren’t linked to any report remain on the Articles table. I can show only the articles that is linked to a report but I would like to know if there is a way to delete the articles table’s row that aren’t linked.
Opening a new form from report screen I can’t see Articles Table, so I try do to this in the sub-form to create new articles. In this way the ghost articles remain until I create and submit a new article. But doesn’t work.
New column is a relation column that is linked to the report table, so the articles that is on a report has a link, and the articles that i’m working with has the Id that is the user Id created.
Add a query in the user profiles table, query all articles that have a unique ID, but the relation to the “Report” table is empty (meaning “ghost” articles).
Delete them through the query before entering your form.
Yeah in that case your query should filter by the signed-in user’s ID as well, just in case 2+ of you are adding at the same time and you accidentally delete another user’s articles.