0

I am pretty new to coding and just need help on adding/changing the following line in my apex code so it queries the RecordTypeId as well as the OpportunityId from the record that my lightning component button has been actioned from. This RecordType which has the lightning component button is called 'Master PAX' and the RecordTypeId is 0121U000000VqrB. At the moment I have just manually added in the OpportunityId of my Master PAX and all the code is working great, I just need it to populate the OpportunityId and RecordTypeId automatically.

I have been stuck on this for a while and help would be much appreciated.

    List<Quote> lstQuoteResult = new List<Quote>();
            
            List<Quote> lstQuote = [SELECT Id, OwnerId, IsDeleted, Name, CurrencyIsoCode, CreatedDate, CreatedById, LastModifiedDate, 
                                    LastModifiedById, SystemModstamp, LastViewedDate, LastReferencedDate, OpportunityId, Pricebook2Id, 
                                    ContactId, QuoteNumber, IsSyncing, ShippingHandling, Tax, Status, ExpirationDate, Description, 
                                    Subtotal, TotalPrice, LineItemCount, BillingStreet, BillingCity, BillingState, BillingPostalCode, 
                                    BillingCountry, BillingLatitude, BillingLongitude, BillingGeocodeAccuracy, BillingAddress, 
                                    ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry, ShippingLatitude, 
                                    ShippingLongitude, ShippingGeocodeAccuracy, ShippingAddress, QuoteToStreet, QuoteToCity, QuoteToState, 
                                    QuoteToPostalCode, QuoteToCountry, QuoteToLatitude, QuoteToLongitude, QuoteToGeocodeAccuracy, 
                                    QuoteToAddress, AdditionalStreet, AdditionalCity, AdditionalState, AdditionalPostalCode, 
                                    AdditionalCountry, AdditionalLatitude, AdditionalLongitude, AdditionalGeocodeAccuracy, 
                                    AdditionalAddress, BillingName, ShippingName, QuoteToName, AdditionalName, Email, Phone, 
                                    Fax, ContractId, AccountId, Discount, GrandTotal, CanCreateQuoteLineItems, Airline__c, 
                                    Milestone__c, Milest__c, Milestone_Deposit_Date__c, Final_Deposit_Balance_Due__c, 
                                    FInal_Deposit_Balance_Amount__c, Start_Date__c, Product_Interested_In__c, Check_In_Date__c, 
                                    Check_Out_Date__c, Old_Quote__c, Price_Book_Name__c, Sent_to_Customer_Date__c, Price_Per_Person__c, 
                                    Airfare_Required__c, Airfare_Amount__c, Insurance_Required__c, Insurance_Amount__c, Misc_Add_On__c, 
                                    Misc_Add_On_Price__c, Overall_Grand_Total__c, Discount_Applied__c, Per_Person__c, Quotation_Total__c, 
                                    Amount__c, Departing__c, Arrival__c, Departure_Date__c, Arrival_Date__c, Flight__c, Flight_Details__c, 
                                    Insurance_From__c, Insurance_To__c, Number_of_Nights__c, Misc_Add_On_Required__c, Passenger_Names__c, 
                                    Checkout_checkin__c, Final_Payment_Due_Date__c
                                    FROM Quote
                                    WHERE OpportunityId = :'0065500000HMAr5AAH']; 
            
4
  • You add it just like you added all those other fields. Just use the API Name with a comma between each (between SELECT and FROM). Where exactly are you stuck? Have you looked at the documentation (SOQL SELECT Syntax)? – Adrian Larson Dec 11 '20 at 1:40
  • @AdrianLarson Hi Adrian, sorry it is a little hard to explain. I need to add in my desired RecordTypeId (Master Pax - 0121U000000VqrB) into the WHERE line, as I am trying to pull the Quotes from the specific Master PAX Opportunity. – Sophia Dec 11 '20 at 1:54
  • @AdrianLarson So I need to add into the "WHERE" line to select the fields from the Quote where RecordTypeId = 0121U000000VqrB and the OpportunityId is where I'm actioning the lightning component button from. – Sophia Dec 11 '20 at 2:01
  • 1
    The documentation is similarly pretty thorough on WHERE syntax. You can join clauses via AND. Though I highly recommend you filter by RecordType.DeveloperName instead. – Adrian Larson Dec 11 '20 at 2:18

Your Answer

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

Browse other questions tagged or ask your own question.