Cant generate PDF document

0
Hello I’m experiencing some difficulties to generate a document. DOes someone has an idea to unblock me ? As per now, I have no error, but when I click on the button, nothing happen (no error message, nothing...)   I followed the documentation at this link : Creating Your Own Documents - Studio Pro 9 Guide | Mendix Documentation   created a new entity named CustomerRequest_Document Generalized it on System.FileDocument Gave full access to all my roles to this entity Linked this entity by a 1-1 relationship to my CustomerRequest ENtity which has all the informations I want to export I’m surprised I don’t need to create an attribute in Binary mode...   Then prepared a document template called CustomerRequest_PDFTemplate linked to CustomerRequest Not changed any security, as it seems there is no security acess on this type of page?   Then created 1 first microflow to generate the document:   The create activity is set this way. However not sure about the documentation sentence  Set the reference to the Order object (I understand this as the entity – top box) and the name of the document (and this as the output – bottonbox).   Then the Retrieve is done over association   And lastly I generate my document I’m carefull to input as argument the same name as the variable as the start of the microflow. I’m surprised that we have set an output (in my case CustomerRequest_info) in the retrieve activy that seems to not been used   I’m carefull to give full access right to the microflow to all my roles.    Then I create a second microflow to call the first one. The microflow call is done  T Hen I retrive from database the object and lastly I add an activity to downlad the doc   I give all rights to my roles to this microflow.     I link the microflow to a button with such properties I got no error in the console I deploy it, and when I click on the button nothing happen. When I go in the console advanced – database view and do a query on the database, I see that there is nothing in the entity, I suspect that the document is never stored?   Would you have an idea? ps: in fact It even broke my application…. when I reached the page where the button is everything, I can’t click on any button.  
asked
2 answers
0

 

There may be errors on the page. Did you check the browser console (F12 in Chrome) to look for errors there?

I’ve had the same situation on a couple of occasions and each time it was related to access rights. Are the FileDocument and the relevant assocations to and from it accessible for the users? I.e. in your case your will need at least read access from ‘Customer’ to ‘Request’ and (potentially) also from ‘Request’ to ‘Customer’ 

And of course read access to all attributes of the ‘Request’ entity.

answered
0

There are a few things here I will try my best to explain.

Your retrieve for 'CustomerRequest_info' is not necessary and will always be empty as you are retrieving over an association from the created Customer_Request document but your create action has not set any association. You can remove your CR_Info action as you are correct it is not being used.

I think what you mean to do is not retrieve but set an association. You say in the create action you are referencing to the order/CustomerRequest within the 'entity' input box but this is incorrect, you are not setting a reference/association here. You are creating an object of 'CustomerResquest_Document', which is a single entity in your Domain Model; not setting a reference between a CustomerRequest and a Document. To set this, in your CR_Document object add a new member setting the association to your from CustomerRequest parameter. 

Then in your second microflow you retrieve the CR_Document from the database but this will always be empty as you did not commit it in the first microflow. Changes will only be made to the database with a commit. So you should add a commit action at the end after the PDF generation.

You would now have a customer request parameter, create a CR_Document and associate it to this, generate the PDF, and commit it.

In the second microflow you might also want to change things so it's not just retrieving the first entry in the database as if this logic were used in Production you'd have no idea if the first entry is related to the CustomerRequest parameter or not. 
So your retrieve ought to be over the new association created in the first MF. Alternatively set an output on your first microflow to be the $CR_Document object and then in your second MF in the sub-MF action enable using the output variable, so you can then pass this directly to the download without using a retrieve

answered