• sdfht ytuh
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi everyone, I'm  new on LWC . and  I'm doing  this example to generate a PDF https://santanuboral.blogspot.com/2020/10/lwc-generate-pdf.html
everything works fine  but now Im trying to save the PDF to  the  correspondet contact depending on the ID,  any idea of how I can do that?   this is my code as we can see Im hard coding the id 

 
public with sharing class DisplayRichTextHelper {
    @AuraEnabled
public static Attachment generatePDF(String txtValue){

        Pagereference pg = Page.renderAsPDF;
        pg.getParameters().put('displayText', txtValue);

        Contact con = new Contact(Id='0035f000008RNWCAA4');

        Attachment objAttachment = new Attachment();
        objAttachment.Name = 'J2S.pdf';
        objAttachment.ParentId = con.Id;
        objAttachment.Body = pg.getContentaspdf();
        objAttachment.IsPrivate = false;
        insert objAttachment;
        return objAttachment;
    }
}
 

And i want to change for some like this:
 ApexPages.currentPage().getParameters().get('id');
I have been looking at other posts for my questions on how Apex batch works when there is an Error. Somehow I am not able to clear my self. I have couple of questions. Can someone please clarify.

1. Assume a batch process has 3 iterations processing 200 records each. The batch process is doing an insert and I am using Database.Insert with AllorNone parameter set to False. Assume there was an error during the second iteration while processing 101 record.I understand that all the records in the first iteration will be committed and also the 100 records in the second iteration. My question is will the batch process continue to process other records in the second iteration and also the third iteration.

2. Assume all the 3 iterations (execute method) completed without any error but some error occured in the Finish method. Finish method just sends an email. How does this work, considering that I am using Database.Insert and AllorNone parameter set to False. My understanding is that all the records will be committed to the database but user will not be receiving email that the batch was successfull or not. I am confused how this scenario will work in the real time.
  • September 05, 2016
  • Like
  • 1