• Sreekaanth reddy
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
public class ProductLighting {
 @AuraEnabled
    public static Opportunity fetchOpportunityLineItem(String opId) {
        Opportunity returnContactList = new Opportunity();
        
        returnContactList = [Select Id,StageName,(SELECT Id,UnitPrice,Quantity,Discount__c, From OpportunityLineItems Where Approved_c=True) from Opportunity Where Id=:opId];
        
        return returnContactList ;
    }
    
    
    @AuraEnabled
    public static List < String > Records(List < String > lstRecordId) {
        List < String > Msg = new List < String > ();
        List < OpportunityLineItem > lstDeprecateRec = [select Id,Product_Deprecated__c from OpportunityLineItem where id IN: lstRecordId];
        for(OpportunityLineItem ord:lstDeprecateRec)
        {
            ord.Product_Deprecated__c=True;
        }
        allowupdateopplineitem__c obj = allowupdateopplineitem__c.getInstance('isallowed');
        
        obj.allowupdate__c = true;
        update obj;
        Database.SaveResult[] DR_Dels = Database.update(lstDeprecateRec, false);
         obj.allowupdate__c = false;
        update obj;
        for (Database.SaveResult dr: DR_Dels) {
            if (dr.isSuccess()) {
                system.debug('successful Deprecate Opportunity Line Items');
            } 
            }
        return Msg;
        
    }
}