• MandarKhoje
  • NEWBIE
  • 5 Points
  • Member since 2015
  • Developer
  • Salesforce

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
I have created a new Account Lookup field in Quotes. As soon as a user chooses that Account from Account Lookup, it should update AccountId on Opportunity with that lookup account. I created a trigger, but it does not seem to work. 
trigger updateOpptyAccount on Quote (before insert,before update) {
    for (Quote QuoteInLoop : Trigger.new){
        Boolean sMainAccount=QuoteInLoop.Main_Account__c;
        String sQuoteAccountId=QuoteInLoop.Pelco_Account_Name__c;
        String sOptyId=QuoteInLoop.OpportunityId;
        if(sMainAccount ){
            //QuoteInLoop.AccountId=sQuoteAccountId;
            List <Opportunity> Oppty1=[SELECT AccountId from Opportunity where Id = :sOptyId];
             Oppty1[0].AccountId=sQuoteAccountId;
            
        }
    }
}
I am a newbie, would appreciate any help/suggestion.
We upload/create records into our Trading Info custom object tradingInfo__c in Salesforce via the API.  We currently create Trading Info records for each product that a contact has access to trade even when no actual trade has occurred.  I would like to delete all Trading Info records created upon insert if the tradeCount__c =0.  I am new to APEX and would appreciate any assistance.

Thanks,