Upload file to Fibery in Action button

Thanks for that Oleg.
I’ve succeeded in generating a PDF containing the rich text field contents, but I did notice that where I have references to entities in the rich text field, they are replaced by [???] in the output.
I’m guess that there’s no easy fix for this :-/

Please attach example of your template and describe related fibery types schema. Will try to help you with that.

So this is the code I have used within the action button “Attach PDF using template”

    const fibery = context.getService('fibery');
    const x = await fibery.getEntityById(Entity.Type, Entity.Id, ['Name','Description']);
    const markdownContent = await fibery.getDocumentContent(x["Description"].secret, `md`);
    const text = x.Name
<% NAME(text) %>




<%= markdownContent %>

The resultant PDF is named correctly, and contains what I would expect it to, except that any #mention of an entity in the description field shows as [???].

Please give me some time. Will get back to you tomorrow.

Hi, @Chr1sG

Sorry, unfortunately can not be done in a simple way right now. References indeed are returned as [???] from server. The workaround is pretty hard to implement and involves travelling in JSON of document. We will think about fixing the issue. Will let you know.


1 Like

Thanks for getting back to me.
FYI my use case is to be able to create a record of an entity at a particular point in time (e.g. after approval/design freeze).
If the ability to generate PDF from an entity was natively implemented (as discussed here: PDF export of documents - #4 by anayericov) then the support for entity references in markdown would become less important.

1 Like

Actually you can open Entity as View and hit Print in browser. Most contemporary browsers support print into PDF. In that case Entity Mentions will be printed int PDF with their Names.

Hope this helps

Thanks @Viktar_Zhuk
I didn’t make it clear in my post that I was looking for an automated solution, e.g. when state = done, generate a pdf. Unfortunately, I can’t rely on the user to always remember to do it :-/

Thank you a lot.

It works well.
Only the filename argument does not seem to be respected : I get the file in fibery with name “File 16 Jun 2021 08_40_01.pdf” instead of “2021-06-16-F21030004.pdf”

I created a pull request in gitlab with the script
Script for generating pdf file via pdfMonkey and uploading it in fibery (!3) · Merge requests · fibery-community / Action Buttons · GitLab

Hope it will be helpful to others.

Hi, Sylvain

Thanks. Will check the issue with a file name.


@Sylvain_Vuilliot The issue with filename is seems to be fixed and your request is merged.
Thanks for helping.

yes, perfect, thank you for the fix