• Lokesh Kumar
  • SMARTIE
  • 1413 Points
  • Member since 2016
  • Salesforce Developer
  • Informatica


  • Chatter
    Feed
  • 45
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 356
    Replies
...and it sure looks like it's there to me.

I'm doing the tutorial on REST callouts, and the exit test calls for making a class called "AnimalLocator." I created the class, wrote the code for it per the instructions, and ran the tests. When check the challenge, though, I get an error message "Challenge Not yet complete... here's what's wrong: 
No Apex class named 'AnimalLocator' was found."

I've double checked my spelling and capitalization. What rookie mistake might I be making here?

Thanks.
 
Hi all, 

I made few changes to the  one of the Apex classes in UAT, I want to move same class into Production( already same class exist in Production) by useing change sets.

is it like same process adding classes and testclasses into change sets then validation and deploy?? 
why because same test class already exist in prodcution, so do i need to add again test class to the chang set??
which option is suitable during deployment to run test classes among four?? ..i dont want to run all the test classes in prodcution at this case  
Is it going to overwrite the exist class?? 
is there any possible errors can occur during deployment in this case?? 

Thanks in advance.
Hi Team,

I want to get opportunities that are related to case as a related list using VF page.

Can anyone help to fix this?

Thanks & Regards,
Karthikeyan Chandran
I have a trigger on the Opportunity that creates records on a custom object called the Opportunity_Revenue__c. It takes the revenue from the Opportunity and spreads it out over the quarters during the length of the deal. It works fine for insert triggers, I need to have the ability to let users re-create based on a changing contract length / deal length. 

So when the record is updated I want to delete all the records in the custom object Opportunity_Revenue__c that are related to the Opportunity and then run the insert code to create the new records for the Opportunity_Revenue__c object. But it is doubling the records because once it deletes the old records it see trigger as an update and an insert.

Can you help or suggest what I might do?

Here is the code:
 
public class OpportunityRevenueTrigger2 {

    
    public static void updateOpportuntityRev(List<Opportunity> trig){
         List<ID> opprtnyId = new List<ID>();
         Decimal totRev;
         Decimal totAllottedRev;
         Decimal mRev;
         
         for(Opportunity opp4: trig){
            if(Opp4.Auto_Generate_Quarterly_Forecast__c == 'Yes'){
                opprtnyId.add(opp4.id);
            }
         List<Opportunity_Revenue__c> deleteOR = [SELECT id
                                                 FROM Opportunity_Revenue__c 
                                                 WHERE Opportunity__c in: opprtnyID];
         
        if(deleteOR.size() != 0){
           Delete deleteOR;
         }
        
        List<Opportunity_Revenue__c> oppr = new List<Opportunity_Revenue__c>();
        for(Opportunity opp : trig){
             
             if(opp.amount > 0 && opp.contract_length_Months__c > 0 
               && opp.Auto_Generate_Quarterly_Forecast__c == 'Yes' ){
                   Date sDate = opp.CloseDate;
                   Integer period = opp.Contract_Length_Months__c.intValue();
                   Integer period2 = period / 3;
                   totRev = opp.Amount;
                   mRev = totRev.divide(period2, 2);
                   for(Integer i = 1; i <= period2; i++) {
                   Opportunity_Revenue__c oppr2 = new Opportunity_Revenue__c();
                   oppr2.Account__c = opp.AccountId;
                   oppr2.Opportunity__c = opp.id;
                   System.debug('i '+ i);
                   oppr2.ProjectedRevenue__c = mRev;
                   oppr2.Month__c = sDate;
                       if(sDate.Month()== 1 || sDate.month()==2 || sDate.month() ==3){
                           oppr2.Quarter__c =  'Quarter 1, '+string.valueOf(sDate.Year());   
                       } else if (sDate.Month()== 4 || sDate.month()== 5 || sDate.month() == 6){
                           oppr2.Quarter__c =  'Quarter 2, '+string.valueOf(sDate.Year());
                       } else if (sDate.Month()== 7 || sDate.month()== 8 || sDate.month() == 9){
                           oppr2.Quarter__c =  'Quarter 3, '+string.valueOf(sDate.Year());
                       } else if (sDate.Month()== 10 || sDate.month()==11 || sDate.month() ==12){
                           oppr2.Quarter__c =  'Quarter 4, '+string.valueOf(sDate.Year());
                       }
                   
                   oppr.add(oppr2);
                   sDate = sDate.addMonths(3);
                   }
                  
        
              }
        }
        insert oppr;

    }
}
}
 
trigger OpportunityRevenueTrigger on Opportunity (after insert, after update) {
  
        
        OpportunityRevenueTrigger2.updateOpportuntityRev(trigger.new);
        
 
  }

 
Hello Developers!
I am trying to write trigger on opportunity which would sum the Amount field on Account.
This might be possiable via standard but I am trying to have similar trigger on different set of object and solving this would solve the other one as well.
Trigger:
trigger AmountRollup on Opportunity(After insert, After update, After delete, After undelete){
    
    Set<ID> accountIds = New Set<ID>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate || Trigger.IsUndelete){
        For(Opportunity opp: Trigger.New){
            accountIds.add(opp.AccountID);
        }
    }
    If(Trigger.IsDelete){
        For(Opportunity opp: Trigger.Old){
            accountIds.add(opp.AccountID);
        }
    }
    
    List<Account> AccountListToUpdate = New List<Account>();
    Double AmountTotal = 0.00;
    
    
    For(Account a : [Select id, total_opportunity_amount__c, 
                                (Select id, Amount FROM opportunities) 
                                FROM Account WHERE ID = :accountIds])
    {
         For(Integer I = 0; I < a.opportunities.size(); I++)
         {
             AmountTotal += a.opportunities.Amount; // Here I am trying add all amount sum into AmountTotal
             a.total_opportunity_amount__c = AmountTotal;
             AccountListToUpdate.add(a);
         }
                                
    }
    try{
    update AccountListToUpdate;
    }
    catch(Exception E){
        system.debug('Error thrown is: ' + E.getMessage());
    }
}

Thank you for the help!
We are trying to install app from appexchange in sandbox and getting [Exception, DomainNotPropagated] error.

An error has occurred in the following section: [Exception, DomainNotPropagated]. Salesforce.com has been notified of this error.

How do we resolve? We have been on a custom domain for over a year in sandbox and production.
<apex:page standardcontroller="comingpeople__c"   sidebar="false" showHeader="false">
<apex:form >

<apex:pageBlock >
<apex:pageBlockSection title="OUTING PLAN">
<apex:inputField value="{!comingpeople__c.Employee_name__c}" /><br/>
<apex:inputField value="{!comingpeople__c.GID__c}" /><br/>
<apex:inputField value="{!comingpeople__c.coming_or_not__c}" /><br/>
<apex:inputField value="{!comingpeople__c.Transportation__c}" /><br/>
<apex:inputField value="{!comingpeople__c.Venue__c}" /><br/>
</apex:pageBlockSection>

<apex:commandButton value="save" action="{!save}"  />

</apex:pageBlock>
</apex:form>
</apex:page>
In Setup, I have so many apex classes or VF pages, I dont want to browse page by page to locate a class, I have used Quick Find/Search box to find a class but it returns 0 item.
I have to browse every page to find a class, it is very inconvenient.
Please tell me how to find quickly a class or Vf page.

thanks

 
I'm trying to build [Change] link next to record owner name on the lead VF page so that the user can re-assign the leads. My lead VF page is a completely custom build page. I'm expecting this functionality to work as in Standard page ie., when the user clicks the [Change] link he/she should be taken to the change ownership page from where he/she should re-assign the lead and the retUrl should take him/her back to the custom page.

I have used the below piece of code found in this forum - 
<apex:outputLink value="{!URLFOR($Action.Lead.ChangeOwner,Lead.id)}">[Change]</apex:outputLink>

But it's not working as expected. When I add this code and tested by clicking the output link [Change] it asks me to log in again and gives me an error as - 
Stale Session Exception
The page you submitted was invalid for your session. Please try your action again. 

Can I get some help here? 
Are there any advantages to using the Force.com Migration Tool instead of just using the Deploy/Retrieve options in Workbench? Thanks in advance for your help.

Hi,

We have created an apex class and 2 triggers which execute once a registration record is created/updated in order to update the record based on certain criteria.
From this we have noticed that in the mornings the registration process can be quite slow for some users and in some cases they will get the request timed out error message.
When a system admin tries it, sometimes its slow but most of the time we can create the registration fairly quickly.

Is there anything that I should check to maybe increase the request time of the users/triggers? I've never got an error like this and we never had the error in any of our sandboxes - it just appears to be production.
Does anyone know how to resolve this/had a similiar problem?

Thanks.

Hello,

I have a VF text like below
<apex:outputText value="{!cObj.Type__c}" style="font-weight: bold;color: black;font-size: 160%;"/>

I want to control the CSS based on Type__c value
if(Type__c == XYZ)
    style="font-weight: bold;color: black;font-size: 160%;"
else
    style="color: black;"

Thanks for suggestion !
 I need a calculating field ---  calculate days taken to change from open to verified status.

There is a Lead Status picklist  on Account object   -- open ---> Verified.
.
Let me know if you need more info.
Hi, 

Some questions with respect to the Report module.  Here is a report that we have and it has the relationship like this.

Levels for the Reports

Question : In the above screenshot on the top it shows Opportunities (A). The other three are relationships are below that.
Can we have another relationship like Opportunities to a new relationship (E) and E is not related to B or C or D.   We need this new relationship for our project. Need to explore if this is possible or we have to do only by means of development ? 

Thanks
Sajiv​


 
Hello,

When i search something in search box from Portal, i can see the people in the salesforce.
How can i block it ?

Thaks for suggestion !
Hi There, Does anybody knows if there is a way to create an opportunity directly when a customer order a service from our company website. Can you do process builder or need a Apex trigger ? Feel free to  direct me to a link with the process builder or trigger solution.
Im a newbie , On click of a custom button i need message to popup like xyz , but it shoul have ok or cancel.. If ok then it should proceed to the  operation , if cancell then just no action
Well this is odd...I'm doing a very simple Apex module and just copy / paste code, save and then error on Verify Step.

I tried this in 2 orgs and received the same error.  I even went onto the next steps that run the code and those passed but this one didn't.

Thoughts?

User-added image
Hello Geeks,

Wants to know more about how we can whitelist IP's at Profile Level instead of manually.
I want to know is there a way to add IP's Programmatically through API's.

Any suggestion appreciated 

Thanks
Lokesh
Hello Geeks,

we have a requirement to do a call out whenever any deployment is happing in the Org,

Why Is it required?

We want to hit an URL if the deployment components having particular component only in Apex Class. URL is for executing the test cases in the third party system. 

So is there any way to look into the deployment Components programmatically. (API's)

Any Help much appreciated.

Thanks
Lokesh
I am trying to pass Set of Ids in the where clause at the time of setEndPoint URL for more PFB.
Map<ID,ApexClass> apexclassName 		= new Map<Id,ApexClass>([select id,name from ApexClass where NamespacePrefix = null]);
        Map<ID,ApexTrigger> apexTriggerName 	= new Map<ID,ApexTrigger>([select id,name from ApexTrigger where NamespacePrefix = null]);
        Set<ID> apexandTriggerID = new Set<Id>();
        apexandTriggerID.addAll(apexTriggerName.keySet());
        apexandTriggerID.addAll(apexclassName.keySet());
        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        req.setEndpoint(URL.getSalesforceBaseURL().toExternalForm()+'/services/data/v37.0/tooling/query/?q=Select+ApexClassorTriggerId,NumLinesCovered,NumLinesUncovered,Coverage+from+ApexCodeCoverageAggregate+where+ApexClassorTriggerId+IN+(+'+apexandTriggerID+')');
        req.setMethod('GET');
        Http h = new Http();
        HttpResponse res = h.send(req);

the value which is getting assigned is like.

21:08:27:041 USER_DEBUG [12]|DEBUG|***System.HttpRequest[Endpoint=https://informatica--Lokesh.cs41.my.salesforce.com/services/data/v37.0/tooling/query/?q=Select+ApexClassorTriggerId,NumLinesCovered,NumLinesUncovered,Coverage+from+ApexCodeCoverageAggregate+where+ApexClassorTriggerId+IN+(+{01p550000001F7QAAU, 01p550000001F7RAAU, 01p550000001F7SAAU, 01p550000001F7TAAU, 01p550000001F7UAAU, 01p550000001F7VAAU, 01p550000001F7WAAU, 01p550000001F7XAAU, 01p550000001F7YAAU, 01p550000001F7ZAAU, ...}), Method=GET]
 
can anyone help me how to pass return false; in the ng-click event while opening a PrimaryTab using salesforce service cloud console. This is to stop refreshing the main page after clicking on a link.
 
<tr ng-repeat="case in Caseinformation|orderBy:sortType:sortReverse |      filter:query " style="height:1px;" class="data-row">          
     <td style="text-align:left;"><a ng-href="/{{case.caseId}}" ng-click= "openPrimaryCaseTab(case.caseId,case.caseNumber);return false">{{case.CaseNumber}}</a></td>

$scope.openPrimaryCaseTab = function (recordID,caseNumber) {
    alert('open primary tab'+recordID);
    sforce.console.openPrimaryTab(null,recordID,true,caseNumber); 
    }



 
Not able to pass this Challenge PFB screen shot.
My Save Method code.

 
public PageReference save(){
        PageReference savePage;
        if (Schema.SObjectType.Resource_Type__c.isCreateable()){
            try{

                insert rtype;

                String completion = ApexPages.currentPage().getParameters().get('finishURL');
                system.debug('First$'+completion);
        if(completion.startsWith('/')){
        system.debug('Second$'+completion);
            completion.replaceFirst('/','');
system.debug('Third$'+completion);
        }
        savePage = new PageReference('/'+completion);
        
        savePage.setRedirect(true);
        return savePage;
            

            }catch (exception e){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'Unable to update requisitions.  Exception: ' + e.getMessage()));
                return null;
            } 
        }else{
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'You do not have permission to update requisitions'));
            return null;
        }
    }


User-added image 
can anyone please help me here I am not able to solve this challenge.

User-added image
Can somebody please help me out here how to measure based on the sum of # instead of a count of rows or sum of the amount because on my case # is not appearing on the creating lens window Thanks in advance. PFB more details.

User-added image
can somebody help me her am not able to pass this module stuck in the last challenge for more details PFA.

User-added image

User-added image

 
We have a requirement to get the overall test class coverage and individual classes there in salesforce production org. automatically based on time interval. The challenge is how to execute it programmatically and get the latest coverage? 
 Thanks in Advance 
-Lokesh
Create a dashboard named Sales Focus and add the reports you set up earlier in this module.
Add a component based on the Upgrades (Last Month) report as a gauge component.
Add a component based on the Key Accounts report as a horizontal bar chart component.
Check challenge


Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge.
Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: LNEWIXXM

User-added image
I am quering a name from the user object by providing in text box and displaying as dynamic record choice. but if the provided user is not exist i want to display a message that the requested user in not present. how to handle no result in visual flow dynamic record choice
currently we are running via manual clicking on the batches. could you please suggest an option to automate apttus job.

these are the apttus batch jobs update.
Requirement:
I want to create an app which update the user information like profile, email,license etc. and give it to service desk engineer so the can solve the ticket related to user detail modification by own.
For the above requirement modify-all permission is required, but i want to do this without any dependency of an logged-in user means in system-mode context.
Please suggest some ideas.

i tried visual flow and process-builder but i get to know that visual flow run's in a user-mode and process-builder doesn't support screen. only we can execute the auto-flow(which doesn't have screen to take the input from the user).
Can somebody please help me out here how to measure based on the sum of # instead of a count of rows or sum of the amount because on my case # is not appearing on the creating lens window Thanks in advance. PFB more details.

User-added image
...and it sure looks like it's there to me.

I'm doing the tutorial on REST callouts, and the exit test calls for making a class called "AnimalLocator." I created the class, wrote the code for it per the instructions, and ran the tests. When check the challenge, though, I get an error message "Challenge Not yet complete... here's what's wrong: 
No Apex class named 'AnimalLocator' was found."

I've double checked my spelling and capitalization. What rookie mistake might I be making here?

Thanks.
 
I'd like to send a message to the user when something isn't found in one of the tables that my flow uses-  with a message letting them know the product is not found and then have them click OK to acknowledge it- and return to the flow
Hello Guys,

i have followed this document https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_flows_getting_values.htm on passing the value from the visual workflow unto the vf page. But the variable value is not passed real time. I have subflows before every assignment element. With the behavior of Assignment Element 1 VarA -> Subflow1 - Assignment Element 2 VarB - Subflow2 - Assignment Element 3 VarC.
whenever the next subflow is triggered instead of getting Assignment Element 2 VarB on Subflow 2 i am getting Assignment Element 1 VarA .

Is this related to flow caching the variables? 

Thank you in advance.
I can schedule a class in Sandbox but not in production. It showing error like "An error has occurred in the following section: [Exception, InvalidScheduledApexClass]. Salesforce.com has been notified of this error."

Can any one help me on this ?
Hello all, I am going through Trailhead and i got really stuck in one challenge under Admin Beginner, Reports and Dashboards, Extend Your Reporting Strategy with the AppExchange Challenge. There is a high chance i messed up big time so i tried to uninstall the app i was suppose to practise on and it does not even let me do that as there ate various dependencies but i do not get any other option - to delete the dependencies for example. I do not think it's easy to track my steps back in anymore so can you please help unistall the app so i can start from scratch?
Thanks!
Katerina  

I want to check whether a Rich text field named as "Contact_Image" is blank or contains an image in a record.
If the field contains an image i want to display it on a vf page (using soql query in a custom controller)
but if it is blank i want to display an image from the static resources.
is it possible??
 

Hello,

Is it possible to overide the standard "New"button like below to autopopulate few values for object "Account"
User-added image

thanks for suggestion
Hi Developer,
I want to trace an apex class let say class A. Basically it is an email service. When i am sending an email to particular email service address,Class A should invoke but it's not happening. To trace the class i have ganereted debug log for user as myself.
But i am not getting any entry in debug log. Wheareas for other email service i am getting debug log.

Any Help would be appriciated. 
Hi all, 

I made few changes to the  one of the Apex classes in UAT, I want to move same class into Production( already same class exist in Production) by useing change sets.

is it like same process adding classes and testclasses into change sets then validation and deploy?? 
why because same test class already exist in prodcution, so do i need to add again test class to the chang set??
which option is suitable during deployment to run test classes among four?? ..i dont want to run all the test classes in prodcution at this case  
Is it going to overwrite the exist class?? 
is there any possible errors can occur during deployment in this case?? 

Thanks in advance.
Hi,

I have a requirement where i want to save the labels of selected checkboxes in a textarea field.
I am pasting my code below. Please help me for the same
My Class:

public class getLabel{

public List<sObjectWrapper> wrappers{get;set;}  
public List<String> AllLabels{get;set;}
public getLabel(ApexPages.StandardController controller) {
AllLabels = new List<String>();

String type = 'ProposalFields__c';
Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe();
system.debug('Map is --------------->'+m);

Schema.SObjectType s= m.get(type);
system.debug('Type is--------->'+s);

Map<String, Schema.SObjectField> fieldMap = s.getDescribe().fields.getMap();
system.debug('FieldMap is------------->'+fieldMap);

for (String fieldName: fieldMap.keySet()) {
System.debug('Field API Name*********'+fieldName);       // list of all field API name
String label = fieldMap.get(fieldName).getDescribe().getLabel();   //It provides to get the object fields label.
system.debug('Label is----------------->'+label);
AllLabels.add(label);
}
}

public class sObjectWrapper{  
    public boolean isSelected{get;set;}  
    public ProposalFields__c prop{get;set;}  
    public sObjectWrapper(ProposalFields__c prop,Boolean isSelected){  
    this.prop= prop;  
    this.isSelected = isSelected;  
 }  
 }

}


VF Page

<apex:page showHeader="false" sidebar="false" standardController="Proposal_Form__c" extensions="getLabel">
<apex:form >
<style>
.panelWrapper .mainTitle {
   
    
}
</style>
<apex:outputPanel styleClass="panelWrapper" layout="block">
<apex:pageBlock title="Proposal Form">
<apex:pageBlockSection title="Service Requirements">
<apex:inputField value="{!Proposal_Form__c.Service_Family__c}"/>
<apex:inputfield value="{!Proposal_Form__c.Service_Type__c}"/>
<apex:inputField value="{!Proposal_Form__c.Sub_Service_Category__c}"/>
</apex:pageBlockSection>

<apex:pageBlockButtons location="Bottom">
<apex:commandButton value="Save" action="{!Save}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Available fields">
<apex:pageBlockTable var="lab" value="{!AllLabels}">
<apex:column headerValue="Labels">{!lab}</apex:column>

<apex:column >   
<apex:inputCheckbox />
</apex:column> 

</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>

</apex:form> 
</apex:page>

 
Hi Team,

I want to get opportunities that are related to case as a related list using VF page.

Can anyone help to fix this?

Thanks & Regards,
Karthikeyan Chandran
I have a trigger on the Opportunity that creates records on a custom object called the Opportunity_Revenue__c. It takes the revenue from the Opportunity and spreads it out over the quarters during the length of the deal. It works fine for insert triggers, I need to have the ability to let users re-create based on a changing contract length / deal length. 

So when the record is updated I want to delete all the records in the custom object Opportunity_Revenue__c that are related to the Opportunity and then run the insert code to create the new records for the Opportunity_Revenue__c object. But it is doubling the records because once it deletes the old records it see trigger as an update and an insert.

Can you help or suggest what I might do?

Here is the code:
 
public class OpportunityRevenueTrigger2 {

    
    public static void updateOpportuntityRev(List<Opportunity> trig){
         List<ID> opprtnyId = new List<ID>();
         Decimal totRev;
         Decimal totAllottedRev;
         Decimal mRev;
         
         for(Opportunity opp4: trig){
            if(Opp4.Auto_Generate_Quarterly_Forecast__c == 'Yes'){
                opprtnyId.add(opp4.id);
            }
         List<Opportunity_Revenue__c> deleteOR = [SELECT id
                                                 FROM Opportunity_Revenue__c 
                                                 WHERE Opportunity__c in: opprtnyID];
         
        if(deleteOR.size() != 0){
           Delete deleteOR;
         }
        
        List<Opportunity_Revenue__c> oppr = new List<Opportunity_Revenue__c>();
        for(Opportunity opp : trig){
             
             if(opp.amount > 0 && opp.contract_length_Months__c > 0 
               && opp.Auto_Generate_Quarterly_Forecast__c == 'Yes' ){
                   Date sDate = opp.CloseDate;
                   Integer period = opp.Contract_Length_Months__c.intValue();
                   Integer period2 = period / 3;
                   totRev = opp.Amount;
                   mRev = totRev.divide(period2, 2);
                   for(Integer i = 1; i <= period2; i++) {
                   Opportunity_Revenue__c oppr2 = new Opportunity_Revenue__c();
                   oppr2.Account__c = opp.AccountId;
                   oppr2.Opportunity__c = opp.id;
                   System.debug('i '+ i);
                   oppr2.ProjectedRevenue__c = mRev;
                   oppr2.Month__c = sDate;
                       if(sDate.Month()== 1 || sDate.month()==2 || sDate.month() ==3){
                           oppr2.Quarter__c =  'Quarter 1, '+string.valueOf(sDate.Year());   
                       } else if (sDate.Month()== 4 || sDate.month()== 5 || sDate.month() == 6){
                           oppr2.Quarter__c =  'Quarter 2, '+string.valueOf(sDate.Year());
                       } else if (sDate.Month()== 7 || sDate.month()== 8 || sDate.month() == 9){
                           oppr2.Quarter__c =  'Quarter 3, '+string.valueOf(sDate.Year());
                       } else if (sDate.Month()== 10 || sDate.month()==11 || sDate.month() ==12){
                           oppr2.Quarter__c =  'Quarter 4, '+string.valueOf(sDate.Year());
                       }
                   
                   oppr.add(oppr2);
                   sDate = sDate.addMonths(3);
                   }
                  
        
              }
        }
        insert oppr;

    }
}
}
 
trigger OpportunityRevenueTrigger on Opportunity (after insert, after update) {
  
        
        OpportunityRevenueTrigger2.updateOpportuntityRev(trigger.new);
        
 
  }

 
Hello Developers!
I am trying to write trigger on opportunity which would sum the Amount field on Account.
This might be possiable via standard but I am trying to have similar trigger on different set of object and solving this would solve the other one as well.
Trigger:
trigger AmountRollup on Opportunity(After insert, After update, After delete, After undelete){
    
    Set<ID> accountIds = New Set<ID>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate || Trigger.IsUndelete){
        For(Opportunity opp: Trigger.New){
            accountIds.add(opp.AccountID);
        }
    }
    If(Trigger.IsDelete){
        For(Opportunity opp: Trigger.Old){
            accountIds.add(opp.AccountID);
        }
    }
    
    List<Account> AccountListToUpdate = New List<Account>();
    Double AmountTotal = 0.00;
    
    
    For(Account a : [Select id, total_opportunity_amount__c, 
                                (Select id, Amount FROM opportunities) 
                                FROM Account WHERE ID = :accountIds])
    {
         For(Integer I = 0; I < a.opportunities.size(); I++)
         {
             AmountTotal += a.opportunities.Amount; // Here I am trying add all amount sum into AmountTotal
             a.total_opportunity_amount__c = AmountTotal;
             AccountListToUpdate.add(a);
         }
                                
    }
    try{
    update AccountListToUpdate;
    }
    catch(Exception E){
        system.debug('Error thrown is: ' + E.getMessage());
    }
}

Thank you for the help!