• Tad Matjusenko
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 9
    Replies
Hello and thank you in advance,

I have this trigger: 
 
trigger preventSigAccDeletion on Account (before delete) {
        for(Account acc : trigger.old){
            if( acc.Contact_type__c.contains ('Signatory')
             &&  acc.Status__c == 'Approved'){
           
            
            

acc.adderror('Signatory Accounts cannot be deleted. Please contact administrator if you need it to be deleted or merged');
}}}
Contact_type__c is a multi picklist
Status__c is a standard picklist

When I try to delete record where Contact_type__c is blank then the code throws following error: 
Apex trigger preventSigAccDeletion caused an unexpected exception, contact your administrator: preventSigAccDeletion: execution of BeforeDelete caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.preventSigAccDeletion: line 3, column 1

Thank you all.

Hi all,

I am trying to write trigger which throws an error on account delete if Contact Type contains Signatory and Application Status is Approved.

Code works fine if I only try to write trigger based on Contact Type field, but when I try to add second condition it does nothing.

trigger preventSigAccDeletion on Account (before delete) {
        for(Account acc : trigger.old){
            if( acc.Contact_type__c.contains ('Signatory')
             && acc.Application_status__c == 'Approved')
           
            
            acc.adderror('Signatory Accounts cannot be deleted. Please contact administrator if you need it to be deleted or merged');
}
}

Thanks in advance.

 
Hi All,

We have object Fee which is child of the Account object. Fee is calculated once a year per account and we need to display most recent Fee on Account level. 

Current fee is stored in Fee_Amount__c field and ti is a formula field which holds currence data type.

We need to display Fee_Amount__c value on Account level from most recently created Fee record.

Thank you in advance
Hi all,

I am trying to write trigger which throws an error on account delete if Contact Type contains Signatory and Application Status is Approved.

Code works fine if I only try to write trigger based on Contact Type field, but when I try to add second condition it does nothing.

trigger preventSigAccDeletion on Account (before delete) {
        for(Account acc : trigger.old){
            if( acc.Contact_type__c.contains ('Signatory')
             && acc.Application_status__c == 'Approved')
           
            
            acc.adderror('Signatory Accounts cannot be deleted. Please contact administrator if you need it to be deleted or merged');
}
}

Thanks in advance.

 
Hi All,

We have object Fee which is child of the Account object. Fee is calculated once a year per account and we need to display most recent Fee on Account level. 

Current fee is stored in Fee_Amount__c field and ti is a formula field which holds currence data type.

We need to display Fee_Amount__c value on Account level from most recently created Fee record.

Thank you in advance