• Debra Shoup
  • NEWBIE
  • 10 Points
  • Member since 2015
  • Corporate Salesforce.com Administrator
  • AZZ Inc.

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
As an admin, I've written my first apex trigger and it works great in the dev sandbox. But I need to write the test class for it so I can move it to production. I've tried to follow some of the previous questions, but I still am having difficulty. I'm hoping someone can tell me where I've gone wrong. 

My trigger is such that if the account has an Oracle account number entered in the custom field Oracle Account Number, the account cannot be deleted.

Here is my trigger:

1 trigger AccountBeforeDelete on Account (before delete) {
2 for (Account acc: trigger.old){
3 if(acc.Oracle_Account_Number__c!=null){
4 acc.adderror('This Account contains an Oracle Account Number and cannot be deleted. Please contact your System Administrator if you think this account needs to be deleted.');
5 }
6 }
7
8 }
 
 
Here is the apex class I’ve attempted to write:
 
1 trigger AccountBeforeDelete on Account(before delete){
2 for (Account acc:trigger.old){
3 if(acc.Oracle_Account_Number__c!=null){
4 acc.addError('This account is associated with an Oracle Account Number and cannot be deleted. Please contact your System Administrator if you think this account needs to be deleted.');
5 }
6 }
7              
8 }

Thank you!
I am working in the beginning Wave Analytics Basics module and am not able to access Wave Analytics in my Trailhead Developer Org to import the Wave Analytics training data. Any ideas as to how to get that?
As an admin, I've written my first apex trigger and it works great in the dev sandbox. But I need to write the test class for it so I can move it to production. I've tried to follow some of the previous questions, but I still am having difficulty. I'm hoping someone can tell me where I've gone wrong. 

My trigger is such that if the account has an Oracle account number entered in the custom field Oracle Account Number, the account cannot be deleted.

Here is my trigger:

1 trigger AccountBeforeDelete on Account (before delete) {
2 for (Account acc: trigger.old){
3 if(acc.Oracle_Account_Number__c!=null){
4 acc.adderror('This Account contains an Oracle Account Number and cannot be deleted. Please contact your System Administrator if you think this account needs to be deleted.');
5 }
6 }
7
8 }
 
 
Here is the apex class I’ve attempted to write:
 
1 trigger AccountBeforeDelete on Account(before delete){
2 for (Account acc:trigger.old){
3 if(acc.Oracle_Account_Number__c!=null){
4 acc.addError('This account is associated with an Oracle Account Number and cannot be deleted. Please contact your System Administrator if you think this account needs to be deleted.');
5 }
6 }
7              
8 }

Thank you!
I am working in the beginning Wave Analytics Basics module and am not able to access Wave Analytics in my Trailhead Developer Org to import the Wave Analytics training data. Any ideas as to how to get that?