• Vikrum Jaitly
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hi All,
I'm new to salesforce and started working on Trailhead's. I facing issue with the Trigger Challenge. Here is the triger code im writing 

trigger AccountAddressTrigger on Account (before insert) {
    for(Account a : Trigger.new){
        if(a.Match_Billing_Address__c && a.BillingPostalCode != null){
            a.ShippingPostalCode = a.BillingPostalCode;
        }
    }
    
}

but i'm getting the following error. Not sure where i'm doing wrong. can someone please help me here. Thanks in advance.

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, TestTrigger: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.TestTrigger: line 3, column 1: []
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [ContactField__c]: [ContactField__c]


Getting above error..while submitting an assignment.
Question: Create a rollup summary field that determines the potential value of the opportunities associated with an account.
Hi all,

I'm relatively new to Apex and I have been studying the Apex for non-coders. I have run into a snag in that the code I am including below runs in Execute Anonymous on Force.com IDE, but won't run in the main window so I can't save it to the server. I am using windows 8, Eclipse 4.4, Force.com IDE 33.0 and have no problems with anything else. On line 10 it gives me: unexpected syntax: missing EOF at 'BankAcct'
I haven't been able to fix the error (I tried deleting the curly brace, adding one, moving things around, nothing worked) and can't spot any syntax errors otherwise (since it runs in Execute Anon,) so anyone got ideas? Thanks!

public class BankAcct {
     private integer balance = 0;
     public string acctName;
       public string accttype;
       public void makeDeposit (integer deposit){
           balance = balance + deposit;
        }
    public integer getBalance() {
          return balance;
    }

BankAcct chkAcct = new BankAcct();
chkAcct.accttype = 'Checking';
chkAcct.acctName = 'D.Castillo-Chk ';
chkAcct.makeDeposit(150);
BankAcct savAcct = new BankAcct();
savAcct.accttype = 'Savings';
savAcct.acctName = 'D.Castillo–Sav';
savAcct.makeDeposit(220);
List <BankAcct> bankAccts = new List<BankAcct>();
System.debug('The BankAcct List has ' + bankAccts.size() + ' bank  accounts.');
bankAccts.add(chkAcct);
bankAccts.add(savAcct);
System.debug('The BankAcct List has ' + bankAccts.size() + ' bank    accounts.');
System.debug('Here is the list: ' + bankAccts);
For (BankAcct  tempacct:bankAccts)

 system.debug(tempacct.acctName + ' is a ' + tempacct.accttype +' account with a balance of $'+ tempacct.getBalance());
 }