• Matty-T
  • NEWBIE
  • 0 Points
  • Member since 2020
  • Software Developer
  • PFL


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi, I have a dilema we have certain clients that would like the 24 hour clock to read 24:00 at the end of the day as oppossed to 23:59 then moving to 00:00 again, how can I get this to read 24:00 instead of the 23:59?
Q) need to update parent record when child is updated. and need to update child when parent is updated. field city__C.
i have implemented after update which works fine in 2 individual scenarios. but when i combine the code im getting error.
code snippet:
trigger Child_update on Account (after update) {
    set<id> accid = new set<id>();
    list<account> acclist1 = new list<account>();
    list<account> upd = new list<account>();
     boolean vardhan;
    list<account> accid1 = new list<account>();
    set<id> acc =new set<id>();
    boolean harsha;
    for(account a:trigger.new){
        accid1 =[select id,name from account where id=:a.id and parentid =null ];
        if(accid1.size()>0){
            harsha =true;
        }
        else harsha=false;
        
        for(Account ab:accid1){
            acc.add(ab.id);
        }
    }
    if(harsha==true){
    list<account> acclist= [select id ,name,city__C,(select id,city__C from ChildAccounts) from account where id in :acc];
    list<account> updatelst = new list<account>();
    system.debug('list of records with child'+acclist);
    
        for(Account a :acclist){
            for(account abc:a.childaccounts){
                abc.City__c=a.City__c;
                updatelst.add(abc);
                system.debug('ayya vachindhi code');
            }
        }
        
        if(!updatelst.isEmpty()){
            update updatelst; 
        }   
 }

//second piece of code:
 if(harsha==false){
    for(account a:trigger.new){
      account[] acclst=[select id,name,parentid,city__c from account where id=:a.id and parentid !=null];
        for(account c:acclst){
        accid.add(c.ParentId);
        }
    }
    acclist1 =[select id,name,city__C from account where id =:accid];
   
    for(account r:trigger.new){
    for(account a:acclist1){
        system.debug('code vachindhi');
        a.City__c=r.city__C;
        upd.add(a);
    }
        }
        if(!upd.isempty()){
update upd;
        }
    }





help me if anyone had similar requirement