Bug 119942 - Mail Merge contains wrong body: data sent is off by one (wrong record index in merged result)
Summary: Mail Merge contains wrong body: data sent is off by one (wrong record index i...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected) release
Hardware: All All
: medium normal
Assignee: Not Assigned
Depends on: 132678
Blocks: Mail-Merge
  Show dependency treegraph
Reported: 2018-09-17 22:57 UTC by brief
Modified: 2020-10-10 12:00 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:

sample ods file (17.98 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-09-17 22:58 UTC, brief
sample odt file (10.37 KB, application/vnd.oasis.opendocument.text)
2018-09-17 22:58 UTC, brief
Another minimal odt file (10.11 KB, application/vnd.oasis.opendocument.text)
2020-10-10 11:54 UTC, Kevin Suo
Another minimal ods file (datasource) (9.13 KB, application/vnd.oasis.opendocument.spreadsheet)
2020-10-10 11:55 UTC, Kevin Suo
merged result 7z from the minimal file (12.43 KB, application/x-7z-compressed)
2020-10-10 12:00 UTC, Kevin Suo

Note You need to log in before you can comment on or make changes to this bug.
Description brief 2018-09-17 22:57:44 UTC
On sending a mailmerge with a datasource of a calc ods file, the data in the mail body does not match the recipients data.

E.g. a mail is sent for mail8@host (data from line 8, column email) with data from line 7.

Steps to Reproduce:
0. Edit the ods file to contain email addresses.
1. Open the odt file.
2. Attach the ods file using the mail merge assistant.
3. Delete the fields and re-add them using the correct data source.
4. Send emails.

Actual Results:
Hi 7,
1  7,00 €
2 14,00 €

Expected Results:
Hi 8,
1  8,00 €
2 16,00 €

Reproducible: Always

User Profile Reset: Yes

OpenGL enabled: Yes

Additional Info:
Version: (x64)
Build-ID: 0c292870b25a325b5ed35f6b45599d2ea4458e77
CPU-Threads: 4; BS: Windows 6.3; UI-Render: Standard; 
Gebietsschema: de-DE (de_DE); Calc: group
Comment 1 brief 2018-09-17 22:58:36 UTC
Created attachment 144965 [details]
sample ods file
Comment 2 brief 2018-09-17 22:58:52 UTC
Created attachment 144966 [details]
sample odt file
Comment 3 brief 2018-09-17 23:02:00 UTC
same behaviour if openGL is disabled
Comment 4 brief 2018-09-17 23:15:39 UTC
After removing the surrounding table, the correct data is used.
Comment 5 Buovjaga 2018-10-13 11:25:40 UTC

You missed instructions: to match the fields to data source entries, double-click them (Vorname, asd, asd2) and pick the columns with the matching names.

Arch Linux 64-bit
Build ID: 6.1.1-1
CPU threads: 8; OS: Linux 4.18; UI render: default; VCL: gtk3_kde5; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group threaded
Comment 6 QA Administrators 2019-10-16 02:29:46 UTC Comment hidden (obsolete)
Comment 7 Kevin Suo 2020-10-10 11:54:50 UTC
Created attachment 166250 [details]
Another minimal odt file

This bug exists for a long time, and still exists on the current master build.

The problem is, when the mail merge file (i.e., the odt file) contains a table, then the merged result would have the 1st record in the 1st result, but the 2nd result still contains the 1st record, the 3rd result contains the 2nd record, and so on, and finally the last record would contain both the last-1 and the last record in the same document.

The problem does not happen if the odt file does not contain a table.

Attached is a minimal odt file.

Steps to Reproduce:

1. Open the "Another minimal odt file", double-click on any of the two fields, then browse "Add database file", choose the "Another minimal ods file" attached to the next comment.

2. Update the two fields to use the datasource you have added in step 1. Save and reopen the odt file.
(LibreOffice may crash at this step, but this may be a different issue and I will report in a separate report)

3. Enable Mail Merge toolbar (View -> Toolbars -> Mail Merge), click once the "Next Mail Merge Entry" (i.e., -> button in the Mail Merge toolbar). Then click "Save Merged Documents -> Save as Individual documents" on the same toolbar. Choose a location and save.

4. Open the merged individual odt files.
--> The 1st result correctly contains the 1st record ("Kevin Suo"). The 2nd result wrongly still contains the 1st record ("Kevin Suo"). The 3rd result wrongly contains both the 2nd record ("Xiujuan Liu") and the 3rd record ("Aixi Suo") in the same file on two different pages.

The expected result is, 1st record in the 1st result, 2nd record in the 2nd result, and 3rd record in the 3rd result.
Comment 8 Kevin Suo 2020-10-10 11:55:24 UTC
Created attachment 166251 [details]
Another minimal ods file (datasource)
Comment 9 Kevin Suo 2020-10-10 12:00:38 UTC
Created attachment 166252 [details]
merged result 7z from the minimal file