0

to all Now I am trying to the update trigger the concept of this trigger is if I written something in the QuoteLineItemTextArea__c in the custom field from the quoteLineItem in the opportunity is updated the same opportunity in opportunityProduct having the custom field named OpportunityProducttextArea__c (condition in quote and opportunity in sync only). So I have written the code followingly, here I have done the half of the code.I only known to the querying quoteline item only

so I want to know how to query the custom field OpportunityProducttextArea__c in the opportunityProduct

My trigger code:

public class CustomSyncHandler {
    public static void UpdateTrigger (List<QuoteLineItem> InsertedQuote) {

        Set<Id> setofProductId = new Set<Id>();
        Set<Id> setofQuoteId = new Set<Id>();
        Set<Id> setofOpportunityId = new Set<Id>();

      for(QuoteLineItem RecordQuoteItem: InsertedQuote){
          //QuoteDetail.get(RecordQuoteItem.QuoteId);//Try to get quote here 
          setofProductId.add(RecordQuoteItem.Product2Id);
          setofQuoteId.add(RecordQuoteItem.QuoteId);

      }
      system.debug('@@@ setofProductId is'+ setofProductId);
      system.debug('@@@ setofQuoteId is'+ setofQuoteId);

       List<Quote> QuoteList = new List<Quote>();

       QuoteList = [SELECT Id,Name,OpportunityId, IsSyncing FROM Quote Where Id IN:setofQuoteId ];

       for (Quote quoteitem: QuoteList){
           If(quoteitem.IsSyncing == True){
           setofOpportunityId.add(quoteitem.OpportunityId);
           }
       }
       system.debug('@@@ setofOpportunityId is'+setofOpportunityId);


       Map<Id,Opportunity> = new Map<Id,Opportunity>([SELECT Id, Name, OpportunityProducttextArea__c FROM OpportunityProduct])

    }
}

here My plan is,If i query that opportunityproduct customfield,

I check the quote is synced to that opportunity then

If quotelineitem in the opportunity's id and the opportunityproduct in the opportunity's id are same then I try to provide update the data from the quoteline item custom field to the opportunityproduct custom field

  • 2
    OpportunityProduct is available as OpportunityLineItem. So perform query on that.Your query should be something like this: SELECT Id, Name, OpportunityProducttextArea__c FROM OpportunityLineItem – Mr.Frodo Nov 7 '16 at 9:30
  • @Mr.Frodo Thanks a lot it's very help ful for my issue – MohanRaj Nov 7 '16 at 9:35
  • can i post this as an answer, if it solved your issue? – Mr.Frodo Nov 7 '16 at 9:42
  • @Mr.Frodo No actually I done the query followingly, but it's give empty result can you tell tha t what is the error in this query, Map<Id,OpportunityLineItem> OppoLineItemMap = new Map<Id,OpportunityLineItem>([SELECT Id, Name, OpportunityProducttextArea__c, OpportunityId FROM OpportunityLineItem WHERE Id IN:setofOpportunityId]); – MohanRaj Nov 7 '16 at 10:12
  • 2
    setofOpportunityId is set of opportunityId, not the set of OpportunityLineItem id.Replace Id with opportunityId and try again – Mr.Frodo Nov 7 '16 at 10:15
2

Points which were helpful for you in solving the problem...

  1. Opportunity Product is the object which shows list of Products related to an opportunity. We refer it as OpportunityLineItem in code.
  2. Filter in WHERE clause refers to the wrong set of records. Replacing Id with OpportunityId could be helpful.
| improve this answer | |

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.