• sai krishna 267
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 10
    Replies
trigger beforeup on Account (before update) {
    for(Account acc:trigger.new){
    acc.name='123';
    }  
    update trigger.new;
}
I have a requirement Account having opportinities and contacts my question is in Account object it has to print opportunities count and contact count by using the custom field and respective names of opportunites and contacts will also printed in  Account.whenever delete the contact or opportunity it will be automatically updated count & name Automatically give me any body propercode for these....
public class opportunityAfterInsertHelper {
    
    public static void OpportunitiesSize(list<Opportunity> triggerNew, map<Id,Opportunity> triggerNewMap) {
        
        set<Id> accountIds = new set<Id>();
        list<Opportunity> acc_List = new list<Opportunity>();
        String OpportunityNames;
        
        for(Opportunity O: triggerNew) {
            if(O.accountId <> null)
                accountIds.add(O.accountId);
        }
        
        for(Account acc : [SELECT id,name,No_Of_Opportunities__c,opp_Names__c,(SELECT id,stagename FROM Opportunity ORDER BY
         CreatedDate ASC) FROM Account WHERE Id IN : accountIds]) {
            contactNames='';
            if(acc.Opportunities.size()>0) {
                acc.No_Of_Opportunities__c = acc.Opportunities.size();
                for(Opportunity c : acc.Opportunities) {
                    OpportunityNames+=O.stagename+';';
                }
                acc.Opportunities_Names__c=OpportunityNames.subString(0,OpportunityNames.length()-1);
            }
            
            
            
            acc_List.add(acc);
        }
        
        if(acc_List.size()>0)
            update acc_List;
    }
}



error is 
Error: Compile Error:
opp_Names__c,(SELECT id,stagename__r FROM Opportunity ORDER BY
^
ERROR at Row:1:Column:81
Didn't understand relationship 'Opportunity' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 14 column 27

can anybody clear the error? any alternatecode for this logic?
 
in batch min-200 max-2000
there is a limitation in batchapex 5 jobs execute at a time
how will execute queues how it will maintain
 
I have a question...I have account record  in that record there is a three opportunities r there. in Account field there is a one custom field its name is all_oppnames__c in that field that all opportunities names will be displayed comma(,) symbol.by using triggers can any bodygive the code for that......
I have a requirement Account having opportinities and contacts my question is in Account object it has to print opportunities count and contact count by using the custom field and respective names of opportunites and contacts will also printed in  Account.whenever delete the contact or opportunity it will be automatically updated count & name Automatically give me any body propercode for these....
in batch min-200 max-2000
there is a limitation in batchapex 5 jobs execute at a time
how will execute queues how it will maintain
 
I have a question...I have account record  in that record there is a three opportunities r there. in Account field there is a one custom field its name is all_oppnames__c in that field that all opportunities names will be displayed comma(,) symbol.by using triggers can any bodygive the code for that......