• afreen nisa 2
  • NEWBIE
  • 20 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Hi all ,

I am creating an apex trigger(before insert,before update) to add the amount of opportunities created by a single user should not exceed n 1000 a single day. I have successfully created for inserting..

But for updating ,while taking sum it is adding the both the record to be updated's existing value and new to be updated value , which it shouldnt be doing and should take only the new updated value for calculating.

so i wrote a if loop with contains , but i am getting compiler error .Please help

list<opportunity> op2= [Select id,name,amount from opportunity where CreatedByID = :UserInfo.getUserId() and createdDate = TODAY];
     decimal sum=0.0;
    // Query for adding existing opportunity amount
   
    if( op2.size() > 0)
    {
        for (opportunity o : op2)
        {
             if(op1.contains(o.id) == 1)
             {
                 sum=sum+o.amount;
                 System.debug('records loop');
             }
        }
    }

error: Compile Error: Method does not exist or incorrect signature: void contains(Id) from the type List<Opportunity> at line 17 column 21

please let me know what i am doing wrong.

Thanks in advance

Hi all ,

I am very new to salesforce and development in general and hence , i am facing this very stupid issues below

All I am trying to do is add records to list and then insert using insert DML statement.

Please help me understand what am i doing wrong in the below 3 code snippets as i am facing compiler errors

1:
global static void method1(){

   list<Account> a =new list<Account>(Name='A1',type='Industry');
     insert a;
   }
}

Error : Missing ')' at ',' at line 7 column 48

2: global static void method1(){

   list<Account> a =new list<Account>();
   a.add(Name='A1');
   Insert a;
 }

 Error: Compile Error: Variable does not exist: Name at line 6 column 10

3: global static void method1(){

   list<Account> a =new list<Account>();
   a[0].add(Name='A1');
 }

Error: Compile Error: Variable does not exist: Name at line 6 column 13

Please please help !!

Hi all ,

I am creating an apex trigger(before insert,before update) to add the amount of opportunities created by a single user should not exceed n 1000 a single day. I have successfully created for inserting..

But for updating ,while taking sum it is adding the both the record to be updated's existing value and new to be updated value , which it shouldnt be doing and should take only the new updated value for calculating.

so i wrote a if loop with contains , but i am getting compiler error .Please help

list<opportunity> op2= [Select id,name,amount from opportunity where CreatedByID = :UserInfo.getUserId() and createdDate = TODAY];
     decimal sum=0.0;
    // Query for adding existing opportunity amount
   
    if( op2.size() > 0)
    {
        for (opportunity o : op2)
        {
             if(op1.contains(o.id) == 1)
             {
                 sum=sum+o.amount;
                 System.debug('records loop');
             }
        }
    }

error: Compile Error: Method does not exist or incorrect signature: void contains(Id) from the type List<Opportunity> at line 17 column 21

please let me know what i am doing wrong.

Thanks in advance

Hi all ,

I am very new to salesforce and development in general and hence , i am facing this very stupid issues below

All I am trying to do is add records to list and then insert using insert DML statement.

Please help me understand what am i doing wrong in the below 3 code snippets as i am facing compiler errors

1:
global static void method1(){

   list<Account> a =new list<Account>(Name='A1',type='Industry');
     insert a;
   }
}

Error : Missing ')' at ',' at line 7 column 48

2: global static void method1(){

   list<Account> a =new list<Account>();
   a.add(Name='A1');
   Insert a;
 }

 Error: Compile Error: Variable does not exist: Name at line 6 column 10

3: global static void method1(){

   list<Account> a =new list<Account>();
   a[0].add(Name='A1');
 }

Error: Compile Error: Variable does not exist: Name at line 6 column 13

Please please help !!