You need to sign in to do that
Don't have an account?
Joshua Anderson 44
I have the above code that gets fields off the OpportunityLineItem... my client would like for it to get different fields if the opportunity has a certain field populated.
public with sharing class BookingReviewPageControllerSynced { public Opportunity myOpp {get;set;} public List<OpportunityLineItem> opportunityProductList{get;set;} /*public String url_redirect {get;set;} public String selectedRedirectProduct{get;set;} public Boolean reloadNeeded{get;set;} */ public BookingReviewPageControllerSynced(ApexPages.StandardController stdController) { this.myOpp = (Opportunity)stdController.getRecord(); getOpportunityProductList(); } public void getOpportunityProductList() { opportunityProductList = new List<OpportunityLineItem>(); System.debug('FARGLE myOpp.ID: ' + myOpp.Id ); for (OpportunityLineItem opL:[SELECT Id, formula_Line_Number__c, Product2Id, ProductCode, Product2.Name, Product2.Supplier_Name__c, Product2.Supplier_Name__r.Name, Product2.Supplier_Name__r.Business_Designation__c, Product2.Hazard_Class__c, Product2.NSN__c, Product2.Reporting_Category__c, Product2.Manufacturer_Product_Number__C, Quantity, Unburdened_Unit_Price_Quote_Line__c, Burdened_Unit_Price_Quote_Line__c, formula_GSA_Remarks__c, Quote_Line_Item__r.GSA_Price__c, Quote_Line_Item__r.Calculated_Usual_Days_to_Ship__c, Product2.ADS_Cost__c, Quote_Line_Item__r.ADS_Cost__c, Quote_Line_Item__r.UnitCost__c, Supplier_Quote_Number__c, Quote_Line_Item__r.Berry_Compliance_Status__c, Quote_Line_Item__r.Country_of_Origin__c, Quote_Line_Item__r.Compliance_Code__c, Quote_Line_Item__r.Supplier_Quote_Number__c FROM OpportunityLineItem WHERE OpportunityId =:myOpp.id ORDER BY Quote_Line_Item__r.Number__c ASC]) { if (opl.Supplier_Quote_Number__c != null && opl.Product2.ADS_Cost__c != opl.Quote_Line_Item__r.UnitCost__c){ opl.Quote_Line_Item__r.ADS_Cost__c = null; } else { opl.Quote_Line_Item__r.UnitCost__c = null; } opportunityProductList.add(opl); } } /* public PageReference redirectToURL(){ // debug String strDebugUrl = '/' + selectedRedirectProduct + '/e?retURL=' + myOpp.id; System.debug('Product ID: ' + opportunityProductList[0].SBQQ__Product__r.Id + ' -- COMPARE -- 01tL0000004XFK8'); System.debug('URL Redirect: ' + strDebugUrl); url_redirect = '/' + selectedRedirectProduct + '/e?retURL=' + myOpp.id; reloadNeeded = true; return null; } */ }how do i set a condition to switch between these
public void getOpportunityProductList() { opportunityProductList = new List<OpportunityLineItem>(); System.debug('FARGLE myOpp.ID: ' + myOpp.Id ); for (OpportunityLineItem opL:[SELECT Id, formula_Line_Number__c, Product2Id, ProductCode, Product2.Name, Product2.Supplier_Name__c, Product2.Supplier_Name__r.Name, Product2.Supplier_Name__r.Business_Designation__c, Product2.Hazard_Class__c, Product2.NSN__c, Product2.Reporting_Category__c, Product2.Manufacturer_Product_Number__C, Quantity, Unburdened_Unit_Price_Quote_Line__c, Burdened_Unit_Price_Quote_Line__c, formula_GSA_Remarks__c, SBQQ__QuoteLine__r.GSA_Price__c, SBQQ__QuoteLine__r.Calculated_Usual_Days_to_Ship__c, Product2.ADS_Cost__c, SBQQ__QuoteLine__r.ADS_Cost__c, SBQQ__QuoteLine__r.SBQQ__UnitCost__c, Supplier_Quote_Number__c, SBQQ__QuoteLine__r.Berry_Compliance_Status__c, SBQQ__QuoteLine__r.Country_of_Origin__c, SBQQ__QuoteLine__r.Compliance_Code__c, SBQQ__QuoteLine__r.Supplier_Quote_Number__c FROM OpportunityLineItem WHERE OpportunityId =:myOpp.id ORDER BY SBQQ__QuoteLine__r.SBQQ__Number__c ASC]) { if (opl.Supplier_Quote_Number__c != null && opl.Product2.ADS_Cost__c != opl.SBQQ__QuoteLine__r.SBQQ__UnitCost__c){ opl.SBQQ__QuoteLine__r.ADS_Cost__c = null; } else { opl.SBQQ__QuoteLine__r.SBQQ__UnitCost__c = null; } opportunityProductList.add(opl); } }
https://trailblazer.salesforce.com/ideaView?id=08730000000KITK
Check it once.
I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.
Thanks.