• Pankaj Sharma 195
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 1
    Replies
https://trailhead.salesforce.com/en/modules/lex_dev_lc_basics/units/lex_dev_lc_basics_forms
it is giveing error ->( Formula expression is required for attribute value in <apex:column> in message at line 4 column 43)

apex class->

public class class2
{
  
    List<Account> a= [select  Type from Account];
    
    public List<Account> getacc()
        {
            return a;
        }
}


Vf page->

<apex:page controller="class2">
   <apex:pageBlock title="List of Accounts">
       <apex:pageBlockTable value="{!acc}" var="a">
           <apex:column value="{a.Name}"/>
           <apex:column value="{a.Type}"/>
      
       </apex:pageBlockTable>
   </apex:pageBlock>
</apex:page>


 
Apex trigger is -->

trigger UpdateEmail on Account (after insert, after update) {
 
    set<Id> acctIds = new set<Id>();
    map<Id, Account> mapAccount = new map<Id, Account>();
    List<Contact> conList = new List<Contact>();
  
   
    for(Account acct : trigger.new) {
        acctIds.add(acct.Id);
        mapAccount.put(acct.Id, acct);
    }
   
    conList = [SELECT Email, AccountId FROM Contact WHERE AccountId IN : acctIds];
    Try{
    if(conList.size()!=null) {
        for(Contact con : conList) {
            con.Email = mapAccount.get(con.AccountId).Email__c;
           }
        update conList;
    }
}
    Catch(DMLException e){
       
    }
}

Test class is -->


@istest
public class testtriggeremail
    {
        static TestMethod void testtriggermail()
            {
                 Account acc = [select Name, Email__c from Account where Name='Demo1' ];
                 acc.Email__c='sharma1@deloitte.com';
                 Test.StartTest();
                 update acc;
                 Test.StopTest();
                
                 List<Contact> con = [select Email from Contact where Account.Name='Demo1'];
                
                 for(Contact c :con)
                     {
                         system.assertequals('sharma@deloitte.com',c.Email);
                     }
                       
            }
    }