• Nazia Pathan 4
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I have installed the Trails Tracker dashboard and it doesn't seem to draw any information. Any ideas?
Hi guys,

I want to display alert or pop up message on account object when an order or quote is created or generated in system.How can i do it using formula field ?

trigger productname on Account(after insert,after update)
{
   
    
        List<Account> lstAccounts = [Select ProductNameCopy__c from Account ];
        List<Opportunity> lstopptys = [SELECT Id, Name FROM Opportunity];
        
        List<Id> oppIds = new List<Id>();
        List<OpportunityLineItem> lstopptylineitem  = [SELECT Id, PricebookEntry.Product2.Name FROM OpportunityLineItem WHERE OpportunityId IN :oppIds];
        for(Opportunity o : lstopptys)
        {
           oppIds.add(o.Id);
         }
         
        
            for(Account objAccount : lstAccounts)
            {
               for(Opportunity objoppty : lstopptys)
               {
                for(opportunitylineitem objopplineitem : lstopptylineitem)
                {
                objAccount.ProductNameCopy__c=objopplineitem.PricebookEntry.Product2.Name;
                update objAccount;
                
                }
                
         }
         }
         }
I am using the above trigger to copy the opportunity product names in a custom field in the account object.

This trigger is saved without error. 

But doesn't copy the product name in the Account's custom field(ProductNameCopy).

 

Please advise!!!