• vinay kumar 1170
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
trigger capture on Appointment__c (after update) 
{
   list<account> acclist = new list<account> ();
    
    for(Appointment__c app: trigger.new)
    {
        if(app.Status__c=='Confirmed' &&  trigger.oldMap.get(app.Id).Status__c=='Visited')
        {
            account acc = new account();
            acc.Patient_Name__c = app.Id;
            acc.Phone_Number__c = app.Contact_Number__c;
            acc.Email__c = app.Email__c;
            
            acclist.add(acc);
        }
    }
    
    if(acclist.size()>0)
    {
        
        try{
            insert acclist;
            }
        catch(System.DmlException e)      
        {
            System.debug(e);
        }
            
    }
    
}
trigger capture on Appointment__c (after update) 
{
   list<account> acclist = new list<account> ();
    
    for(Appointment__c app: trigger.new)
    {
        if(app.Status__c=='Confirmed' &&  trigger.oldMap.get(app.Id).Status__c=='Visited')
        {
            account acc = new account();
            acc.Patient_Name__c = app.Id;
            acc.Phone_Number__c = app.Contact_Number__c;
            acc.Email__c = app.Email__c;
            
            acclist.add(acc);
        }
    }
    
    if(acclist.size()>0)
    {
        
        try{
            insert acclist;
            }
        catch(System.DmlException e)      
        {
            System.debug(e);
        }
            
    }
    
}