Workflow to Auto. Generate PDF / Document at Opportunity Creation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cjblue
    Junior Member
    • Oct 2025
    • 2

    #1

    Workflow to Auto. Generate PDF / Document at Opportunity Creation

    Hello!

    I am trying to utilize Workflows to automatically generate a specific PDF template, as well as a document, and link that document to the opportunity.

    I can see that my conditions are being met, and the workflow is being triggered. However, no PDF/document is appearing on the opportunity. So, I must have something wrong here.

    Below are the text and a screenshot of the formula I am trying to utilize. Any insights the community can offer will be greatly appreciated!:



    // Defining the ID of the PDF template being generated.
    $pdfTemplateId = '68cae75dc3802a542';

    // Definining the PDF's filename using the Opportunity's name.
    $fileName = string\\concatenate(entity\\attribute('name'), '-Agreement.pdf');

    // Generating the PDF and getting the attachment ID.
    $attachmentId = ext\\pdf\\generate('Opportunity', entity\\attribute('id'), $pdfTemplateId, $fileName);

    // Creating a "Document" record.
    $documentId = record\\create('Document',
    'name', $fileName,
    'fileId', $attachmentId
    );

    // Relating the created Document record to the Opportunity.
    record\\relate('Opportunity', entity\\attribute('id'), 'documents', $documentId);



    Click image for larger version

Name:	image.png
Views:	0
Size:	178.7 KB
ID:	122376
  • heint
    Member
    • Jun 2025
    • 36

    #2
    Greetings cjblue,

    Could you please share the whole workflow, including the Action type of the workflow and Detail page?

    And my recommendation will be to remove double slashes "\" and replace them with one: "" as every documentation example says.
    Not record\\create but record\create, etc. Please apply this logic to every tag.

    Comment

    Working...