Why does the PDF Document Generation use the attributes from the Commit before last?

0
Hello all,   I am trying to create a pdf document for a report with the PDF Generation Module. But instead of the attributes from the last commit of the object, the attributes from the commit before last get used to generate the document. When creating the document for the first time, all the placeholder for the attributes stay empty.   The object(that gets filled in by the user before the pdf generation) is commited before it get's used by the pdf generation action and 'refresh in client' is on 'yes'. When looking at the variables while debugging, the attributes of the object are the correct ones from the last commit. But in the pdf the ones before are shown.   I already tried to use a retrieved object to create the pdf but the same problem appears. The attributes in the Debugger are correct but in the pdf not.   What could be the cause and how can i fix this?   Thanks in advance!
asked
2 answers
0

Hi,

 

If you prepare data just before calling the Generate PDF action, be sure to commit everything and then use CommunityCommons.EndTransaction to end your transaction. The Mendix create / change object is in memory. The Mendix commit sends data to the database but holds it under lock until the transaction ends. The PDF generation runs in a separate transaction so it will not see your latest updates. The EndTransaction forces the transaction to end, nails the data in the database and releases the record locks.

answered
0

Hi Katalin,

 

 

Fix PDF showing old attribute values:

 

1. Commit your object (the one filled by the user).

2. Immediately do a “Retrieve object from database” using XPath → retrieve by ID.

3. Use this freshly retrieved object as the input for the PDF Generation action.

4. Then generate the PDF.

 

answered