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
kezia dolakezia dola 

Trigger to get quote line items in order products

Hi All,

I have two objects called Quote Line Items and Order Products. Using trigger I want to update the order products when quote line items are edited.

Any Idea how to do?

Thanks,
Kezia
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Kezia,

Is there any relation between these two objects. If so which is the parent and which object is the child. Can you please let community know more information about it.

Thanks
sunil yogisunil yogi

Hi Kezia,

Please try below code to update Product object from the trigger of quote line items. 

select Best :) if it helps

trigger TriggerUpdateproductsfromQLItem on QuoteLineItem (after update) {
    
    if(Trigger.isAfter && Trigger.isUpdate){
        List<Product2> pList = new List<Product2>();
        for(QuoteLineItem quoteitem : trigger.new){
            Product2 getproduct = [select Id,Name,Description FROM Product2 WHERE Id=:quoteitem.Product2Id];
            getproduct.Description = 'update from trigger';
            pList.add(getproduct);
        }
        
        if(pList.size() > 0){
            update pList;
        }
        
        
    }

}

Thanks

kezia dolakezia dola
Hi Sai Praveen,
 
Both the objects have lookup relationship. I am trying get the quote line items in order products object.

Thanks  
kezia dolakezia dola
Hi sunil yogi,

I have tried below code, but order products are not created when quote line items are created or edited. Quote line Item and Order Product objects have lookup relationship.

trigger TriggerUpdateproductsfromQLItem on QuoteLineItem (after update) {
    
    if(Trigger.isAfter && Trigger.isUpdate){
        List<Product2> pList = new List<Product2>();
        for(QuoteLineItem quoteitem : trigger.new){
            Product2 getproduct = [select Id,Name,Description FROM Product2 WHERE Id=:quoteitem.Product2Id];
            getproduct.Description = 'update from trigger';
            pList.add(getproduct);
        }
        
        if(pList.size() > 0){
            update pList;
        }
        
        
    }

}

Any Idea to do this?

Thanks