Create and Email a PDF in Salesforce with Visualforce, Apex and Flows

Поделиться
HTML-код
  • Опубликовано: 7 дек 2024

Комментарии • 30

  • @ChrisMarquez
    @ChrisMarquez  3 года назад

    Referring to 21:00 - 24:00:
    The checkbox isn't actually needed since we have an email input. We can base the decision to fire the apex action on the email input not being empty when the "email invoice" button is clicked.

    • @trystannieuwenhuis88
      @trystannieuwenhuis88 2 года назад

      True, you can now also use the "was_visited" and select the screen in your decision, in this scenario. Thank you for this video!
      Edit2: you can set required="True" in the email field properties :D

  • @petar147
    @petar147 Год назад

    Good video! Mate you are making my life at work easier two days in a row with these videos xD

  • @zakustolondoo
    @zakustolondoo Год назад

    Excellent video. Thanks for sharing your knowledge

    • @ChrisMarquez
      @ChrisMarquez  Год назад

      No problem. Let me know if there are any topics you want me to cover.

  • @abdellahelbahri8664
    @abdellahelbahri8664 2 года назад

    Great solution thnx !! if only we have access to the test class we would be very grateful

    • @ChrisMarquez
      @ChrisMarquez  2 года назад

      I'm just seeing this comment, sorry about that. Here's a test class: gist.github.com/Christriane/c22a3faaaa4fc6acfb6bb5bc6fe73dad

  • @ahcamuoy2340
    @ahcamuoy2340 10 месяцев назад

    Thank you chris

  • @sandeepaepuri3873
    @sandeepaepuri3873 Год назад

    Hi Chris , Thank you for your video it's very useful. I need it on the Oppertunity record and want to use a quote template instead of a Visualforce page. How can we achieve this?

    • @ChrisMarquez
      @ChrisMarquez  Год назад

      No prob! I'll look into this and will get back to you.

  • @jonbojones4316
    @jonbojones4316 3 года назад

    Hi Chris, nice Video! So is ist possible to enter text into the screen element which is then displayed in the pdf that is created?
    Greetings from Germany

    • @ChrisMarquez
      @ChrisMarquez  3 года назад

      Thanks! Yes it is possible. I'll upload a video on Tuesday but you could do the following:
      - Create variables that have the getter/setter and reference them in your VF Page
      - Create screen elements in the flow and use the "Set Args" assignment to add that to the collection variable.
      - Extract the variables in the InvocableMethod the same way that the accountId and email are.
      - Pass the variables as params into the VF pageReference the same way that the accountId is.
      - Assign the params to the variables you created in step 1 in the constructor just like the accountId.
      Something to note is that there is probably a character limit that you can pass in via the params.
      It may also be possible using a class that has variables with the InvocableVariable annotation. I'm not as familiar with this so I'll look into it and will make a video if I figure it out.

    • @ChrisMarquez
      @ChrisMarquez  3 года назад +1

      Here you go: ruclips.net/video/1Y61KsNjtO8/видео.html

    • @jonbojones4316
      @jonbojones4316 3 года назад

      @@ChrisMarquez hi Chris, i watched it already. Keep up the great work. From now on I'm a proud subscriber. If you ever think about a interesting topic it would be creating .Xlsx with visualforce. Doing xls seems quite easy while xlsx is quite hard to achive

    • @ChrisMarquez
      @ChrisMarquez  3 года назад

      Thank you, I appreciate that. I'll look into.

  • @en6400
    @en6400 2 года назад

    Hey Chris, thank you so much for taking the time to make these videos. I'm a SQL developer now working with Salesforce, so your videos are helping me get a better understanding of programming in Apex. I used this solution for the basis for sending a PDF attachment via email from a flow. It works in my sandbox, but when I go to deploy it in production, it says I only have 74% code coverage. I'm unsure how I would test these particular classes. Are you able to provide any assistance?

    • @ChrisMarquez
      @ChrisMarquez  2 года назад

      Hey E N, glad you found them useful!
      I'll post a test class for this in the next day or two on Github and will update this thread with the link but for now somethings you could do to test (and get the required code coverage) are:
      - Create instance of invoicePDFController
      - Call generatePDF method and then do some assertions such as what is shown in the second half of this stack exchange selected answer: salesforce.stackexchange.com/questions/374496/how-to-write-a-test-class-for-this-below-code-can-anyone-help-me
      Let me know if you have any other questions.

    • @en6400
      @en6400 2 года назад

      @@ChrisMarquez Thanks Chris, I appreciate your help. I'll keep an eye out for your update and will look into your other suggestions in the meantime.

    • @en6400
      @en6400 2 года назад

      @@ChrisMarquez After having at your suggestion, what I'm struggling with is passing the parameters to generatePDF as it's a list.

    • @ChrisMarquez
      @ChrisMarquez  2 года назад

      @E N Here you go: gist.github.com/chrismarquezdev/c22a3faaaa4fc6acfb6bb5bc6fe73dad
      I put some comments in the test class to try to explain what I did. I did make a small change to the InvoicePDFController itself on line 40. Turns out doing a getContent call is not allowed during testing so I added check for that.
      Let me know if you have any questions.

    • @PoojaRaut-uo4xk
      @PoojaRaut-uo4xk Год назад

      @@ChrisMarquez I am not able to get your code on this link. it shows 404 error. You have made an Excellent video.

  • @sushma9325
    @sushma9325 Год назад

    Error: Generate PDF Flow

    An unhandled fault has occurred in this flow
    An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Could you please assist on this

  • @yamatoanshu
    @yamatoanshu 2 года назад

    Excellent... Could you please provide the code?

    • @ChrisMarquez
      @ChrisMarquez  2 года назад +1

      I think I lost the exact files but I do have a Github Gist based on a more recent video that I made: gist.github.com/Christriane/17ab590a6ea486140107687fca79b19f

  • @blah9960
    @blah9960 2 года назад

    Can we generate invoice pdf without email?

    • @ChrisMarquez
      @ChrisMarquez  2 года назад

      Yes, refer to this video for an example: ruclips.net/video/YLeaqe82eJE/видео.html

  • @mutzeejr
    @mutzeejr 2 года назад

    How are you able to get around the need to have the Visualforce page needing to be part of the org's remote site settings?
    I am receiving this error:
    FATAL_ERROR System.VisualforceException: core.apexpages.exceptions.ApexPagesGenericException: The page can't be loaded because the remote site apex/[GeneratePDFPageName] isn't listed in your organization's Remote Sites Settings.
    This is getting hit when attempting to call the pagereference.getContent() method in the controller.