• Cobb Anderson
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
hi devs!
I have one question regarding apex test class.
if I execute several test classes at once, how will the coverage calculate?
please tell me how the 75% coverage is consist of.
Is it the coverage of entire test class? or the last class that was executed in the row?
please help! T_T
hello, mighty developers.
I am new to APEX trigger, so I am having a lot of issue writing simple code.
I tried to write a trigger where an owner can only delete contact record when the contact's account owner is also the same.
there was no syntax error but now everyone cannot delete anything from contact.
so, please, have a mercy on this poor girl and a little help!!

============================================================

trigger Tri_AcContOwner2 on Contact (before delete, before insert, before update)  {
      Integer isa = Trigger.size;
  if(Trigger.isBefore){
     if(Trigger.isInsert || Trigger.isUpdate || Trigger.isDelete){
         Set<id> account_id_set = new Set<Id>{};
         for(Contact z1 : Trigger.new){
             account_id_set.add(z1.AccountId);
                                      } 
         //extract account name
         List<Account> account_list = [SELECT OwnerID From Account WHERE Id IN :account_id_set];
         for(Contact z1 : Trigger.new){
             for(Account z2 : account_list){
                 if(z2.OwnerID != UserInfo.getUserId()){
                     for(integer i = 0; i < isa; i++){
              Trigger.new[i].addError('Only the account owner can play with this');                 
              Trigger.old[i].addError('only the account owner can delete this');         
                         }//last for
                    }//last if
                }//last2 for
            }//last3 for
        }//up2 if
    }//up1 if
}


================================


thanks in advance!!!
Dear Salesforce developers,

I am new to APEX. I've been Salesforce support and consultant only within the scope of admin and configuration.
I am learning how to write trigger these days and I've been successful with most of it, but just this;

============================================================
trigger HW_CountContactQuant on Contact (after delete, after update, after insert) {
    List<Account> accList = new list<Account>();
    integer i = [SELECT Count() FROM Contact];
    
 if(Trigger.isAfter){
     if(Trigger.isInsert || Trigger.isDelete || Trigger.isUpdate){
         for(Contact gh1 : Trigger.old || Trigger.new){
         Account.ContactQuantity__c = i;
         }
     }
 }


}
================================

I am trying to create a trigger whenever Contact is inserted, updated and deleted, it will count the number of records and update certain field in "Account". Like, rollup summary.
there seems to be no error in my syntax but I keep having "Expression cannot be assigned".

Someone please please help? T_T
hello, mighty developers.
I am new to APEX trigger, so I am having a lot of issue writing simple code.
I tried to write a trigger where an owner can only delete contact record when the contact's account owner is also the same.
there was no syntax error but now everyone cannot delete anything from contact.
so, please, have a mercy on this poor girl and a little help!!

============================================================

trigger Tri_AcContOwner2 on Contact (before delete, before insert, before update)  {
      Integer isa = Trigger.size;
  if(Trigger.isBefore){
     if(Trigger.isInsert || Trigger.isUpdate || Trigger.isDelete){
         Set<id> account_id_set = new Set<Id>{};
         for(Contact z1 : Trigger.new){
             account_id_set.add(z1.AccountId);
                                      } 
         //extract account name
         List<Account> account_list = [SELECT OwnerID From Account WHERE Id IN :account_id_set];
         for(Contact z1 : Trigger.new){
             for(Account z2 : account_list){
                 if(z2.OwnerID != UserInfo.getUserId()){
                     for(integer i = 0; i < isa; i++){
              Trigger.new[i].addError('Only the account owner can play with this');                 
              Trigger.old[i].addError('only the account owner can delete this');         
                         }//last for
                    }//last if
                }//last2 for
            }//last3 for
        }//up2 if
    }//up1 if
}


================================


thanks in advance!!!
Dear Salesforce developers,

I am new to APEX. I've been Salesforce support and consultant only within the scope of admin and configuration.
I am learning how to write trigger these days and I've been successful with most of it, but just this;

============================================================
trigger HW_CountContactQuant on Contact (after delete, after update, after insert) {
    List<Account> accList = new list<Account>();
    integer i = [SELECT Count() FROM Contact];
    
 if(Trigger.isAfter){
     if(Trigger.isInsert || Trigger.isDelete || Trigger.isUpdate){
         for(Contact gh1 : Trigger.old || Trigger.new){
         Account.ContactQuantity__c = i;
         }
     }
 }


}
================================

I am trying to create a trigger whenever Contact is inserted, updated and deleted, it will count the number of records and update certain field in "Account". Like, rollup summary.
there seems to be no error in my syntax but I keep having "Expression cannot be assigned".

Someone please please help? T_T