Create a PDF in Salesforce with Visualforce and Apex

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ม.ค. 2025
  • In this video, we go over how to create a PDF within Salesforce using Visualforce and Apex. This is a simple way to generate PDFs from records in your org.
    Get the code in this video here: gist.github.co...
    Submit your questions here:
    docs.google.co...
    Subscribe to my Salesforce Newsletter:
    www.posts.chri...
    Consider subscribing or even buying me a coffee if you find the stuff I post to be useful: ko-fi.com/chri...

ความคิดเห็น • 25

  • @aniketk11
    @aniketk11 4 หลายเดือนก่อน

    Hey Chris, any idea about making this page available as a link from Salesforce Experience Site

  • @anninguyen7772
    @anninguyen7772 3 หลายเดือนก่อน

    Hi Chris, what if the language is in Czech? how could we encode the text?

  • @waljaengel9670
    @waljaengel9670 2 ปีที่แล้ว

    Hi, great work. is there a way to reset html formatting like margin and padding?

  • @NaveenKumar-bc7ef
    @NaveenKumar-bc7ef 2 ปีที่แล้ว

    Hi Chris
    The solution is very simple and easy but in my case, I am using custom objects "Sales_Order__c and Sales_Order_Line_Item,as I am new to this how can I modify this ?

  • @albertoteotliramirezflores9380
    @albertoteotliramirezflores9380 2 ปีที่แล้ว

    Hi, Chris, i need help. I have a problem with a object, because i have one object relationed with other object and giveme the Id objects but i wanted give me a recordsname, what I can do?

    • @ChrisMarquez
      @ChrisMarquez  2 ปีที่แล้ว

      Hi Alberto, it depends on your query and the relationship of the objects. For example, you could do ParentAccountLookupField.NameField if you're querying contacts and want to get the recordName of a parent such as the Account.

  • @megganlandis1549
    @megganlandis1549 2 ปีที่แล้ว

    Hey Chris, hoping you can help with this - your video has been really helpful, and although this is probably really simple, can you tell me what the code would be if I was trying to add a colored border (like you have in this video) that runs the entire width of the page, but just has 'Required Fields' centered in the border? I would GREATLY appreciate it! Thanks!

  • @sushma9325
    @sushma9325 ปีที่แล้ว

    List has no rows for assignment to SObject -- This error is being shown. I'm a beginner. Could anyone assist on this, please

    • @naoufalalaa7295
      @naoufalalaa7295 ปีที่แล้ว

      set an Id in the controller :)

    • @twit1twit17
      @twit1twit17 ปีที่แล้ว

      @@naoufalalaa7295 How can I pass account Id dynamically instead of hard coding using custom controller?

  • @captainfeels8390
    @captainfeels8390 ปีที่แล้ว

    Hey Chris, i hope you're doing well. can you make a video about saving a VFPage as an attachment to an object using getcontentAsPDF? I'm encountering errors and don't know how to solve it. thanks.

    • @ChrisMarquez
      @ChrisMarquez  ปีที่แล้ว

      Feel free to comment the code and error you're encountering. I'll try to help you out.

  • @jonbojones4316
    @jonbojones4316 3 ปีที่แล้ว

    Hi so could i create a pdf with VF and apex class Boy using a Flow?

    • @ChrisMarquez
      @ChrisMarquez  3 ปีที่แล้ว +1

      Hello, not sure if this is what you mean but it is possible to use a flow to generate and email a pdf that is created using VF and Apex.
      I'll create a video that explains how to do so but for now all you would need to do is to create a public static method with the "@InvocableMethod" annotation to let the flow builder know that the method can be run as an invocable action. This method should create an pageReference instance of the the VF Page that you want to make a pdf from. You can then use the getContent method to get the pdf as a blob. Set the email file attachment body to this blob and the email you get from that should contain the pdf.
      Back in the flow builder, create a screen flow with a button or checkbox that will call the invocableMethod as an apex action when submitted.
      Hope this helps.

    • @ChrisMarquez
      @ChrisMarquez  3 ปีที่แล้ว

      This video explains what I wrote above: th-cam.com/video/ZVwPwB1bLTg/w-d-xo.html

  • @beatrisyessayan8767
    @beatrisyessayan8767 2 ปีที่แล้ว

    How Can I create a test class for this generated pdf?

    • @pavankumarv6849
      @pavankumarv6849 2 ปีที่แล้ว

      Hey if you have written class for this then can you please share

  • @annepetersen4745
    @annepetersen4745 2 ปีที่แล้ว

    Hi, This video has been very helpful for me to learn how this all fits together. In your example you have 2 SOQL queries, one for invoiced, one for not invoiced.
    How would I go about doing similar, but instead of explicitly selecting 2 separate SOQL, i wanted to select all Opportunities, not needing to know what the stages are upfront and then displaying in a PDF in separate tables for each stage found. (if that makes sense)
    Any advice much appreciated. Thanks

    • @annepetersen4745
      @annepetersen4745 2 ปีที่แล้ว

      Just to update ... would a list of lists work here? The"outside" list value being stage and the "inside" being all the opportunity details of opps with that stage. Then run a for loop on the outer value for each stage. I can think of this logically, but not experienced enough with apex and vf to work out how to achieve this. Thanks.

    • @ChrisMarquez
      @ChrisMarquez  2 ปีที่แล้ว

      Hello Anne, just uploaded a video discussing this: th-cam.com/video/izZXcxzLguQ/w-d-xo.html

  • @praveenraj290
    @praveenraj290 2 ปีที่แล้ว

    Am having issue, while downloading pdf its blank where as data is there in vs page..any idea to resolve this..thanks

    • @ChrisMarquez
      @ChrisMarquez  2 ปีที่แล้ว

      Hi, happy to help. Can you post your solution in a GitHub gist or in a comment? I'll take a look at it.

  • @jerryraju6293
    @jerryraju6293 5 หลายเดือนก่อน

    Hi can you please provide me that code.

    • @ChrisMarquez
      @ChrisMarquez  5 หลายเดือนก่อน

      gist.github.com/chrismarquezdev/6d82992bc594f2efcc6bec381e5e7e0c

    • @jerryraju6293
      @jerryraju6293 5 หลายเดือนก่อน

      @@ChrisMarquez thanks for sharing