0

In my current org, I have a quick action in the order object, that collect the data of the current order and generates a PDF with the data of that order. The org is entirely in Lightning Experience.

But, the code isn't getting the RecordId properly, the string 'param_recordId' is returning null.

The code:

private final Order Quote;
    
    public String renderAs {get;set;}
    public String contentType {get;set;}
    public List<OrderItem> QuoteItem {get;set;}
    public QuotePDF() {
        String param_renderAs = ApexPages.currentPage().getParameters().get('renderAs');
        String param_recordId = ApexPages.CurrentPage().getparameters().get('id');
        //block to obtain some fields of the referred order.

what I need to do to the class retrieve the current Id from the page where I'm hitting the quick action button?

2
  • 1
    is this quickaction associated to a VF page/controller? if so, you'd get the OrderId from the standardController's getId() method – cropredy Dec 8 '20 at 19:19
  • Yes, it is!! I got it with getId() method. Thanks!! – RedMan Dec 8 '20 at 20:22
1

Assuming this is a VF page/controller on a standard object associated to the quickaction, then you can get the record ID as follows:

public class MyController {
   
   ApexPages.StandardController ctrl;
   Id orderId {
      get {return this.ctrl.getId();} set;
   }
   public Order myOrder {
     get {return [SELECT ... FROM Order WHERE id = :this.orderId];} set;
   } 

   public MyController(ApexPages.StandardController ctrl) {this.ctrl = ctrl;}
}

Note the use of properties to fetch values when needed leaving the constructor at its absolute most basic. Adapt as required for your application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.