function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DurgaPrasadChowdaryDurgaPrasadChowdary 

Getting Records by using the id which has been Used from parameter

Hi Community,

                     I'am facing a problem on getting the record while querying them using the id which is from parameter.

I've created an email service which is used for creating record of an order__c record and invoice__c record which is child for order__c,after creation of the invoice the invoicelineitem is created for that particular invoice__c record & then the invoice details are sending as pdf to the particular account's email-id.

    

                     All these are processing based on the account record id which is sending as csv file for that email service.when salesforce receives the email from any user's mail then the process starts i.e search for the account record and create an order for that record after that an invoice and invoice lineitem and then generate pdf and send that pdf for the email which should specify in the account record.All these process are executed on a single thread.The order is created and invoice is created and invoice lineitem also created sucessfully but coming to PDF generation dynamically for the invoice record the id will be sending as querystring and accessing the id using getParameter .iam able to get id also and then make a query to retrieve the rcord's of the invoice with that invoice an ERxception occurs i.e (Trying to DeReference a null object).

 

                      when trying this same procedure manually that means with out email service it works fine.Could any one find the solution for this one.

 

                       My opinoin is it's a salesforce issue that when querying for data of the record which is created dynamically it should not be committed. 

   

bob_buzzardbob_buzzard

I believe I've encountered this before, but just want to confirm that your scenario is the same as mine.

 

I was inserting a record into the database, then trying to get the contents of a visualforce page as PDF and passing the ID of the newly inserted record on the URL.  Is that essentially what you are doing?

 

It appeared to me that the generation of the page as PDF ran in a different context to my current transaction, so the newly inserted record wasn't visible when generating the PDF, resulting in blank space where fields should have been pulled from the record.  I worked around this using a visualforce email template that generated a PDF.

DurgaPrasadChowdaryDurgaPrasadChowdary

Yes bob,

              For me also like similar problem at the time of PDF generation which contains of the record's  value which is created at that time and using that ID for querying.