function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kumar palepukumar palepu 

unable to save the filed in child

1. Account has two record type 1.filedreadonly 2.Testing.
2. Same filed but testing record type has look up (self__c) for filedreadonly.
3.  now account site filed which is present is testing is automatically update same name   like as site code which is present is filedreadonly. 
I done with inserting, updating, deleting. Now issue is when I insert the new record in testing. The records is creating  but account site value is not saving.please refer the below code and help me to get out from this problem

trigger testsitevalue on account(after insert,after update,after delete) {

Set <Id>  locationId = new Set<Id>();
Set<Id> filedrecord = new Set<Id>();
Set<Id> totalRecords= new Set<Id>();

list<account> newsite = new list<account> ();

RecordType Vendorlocations;
RecordType FiledRead;
    for (RecordType rt: [SELECT Id, Name, DeveloperName FROM RecordType WHERE RecordType.DeveloperName = 'testing'])
    {
        Vendorlocations = rt;
    }
   
    for (RecordType fr: [SELECT Id, Name, DeveloperName FROM RecordType WHERE RecordType.DeveloperName = 'filedreadonly'])
    {
        FiledRead = fr;
    }
              
  if(avoidRecursive.once)
   {
     avoidRecursive.once= false;
    
     
           if(trigger.isdelete)
           {
           List<account> ac =[select self__c,Site from account where RecordType.Name='testing' AND self__c IN : Trigger.oldMap.keyset() ];
          
            for(account del : ac)
           
            { 
              system.debug('Id'+ del.Id);
              system.debug('ID'+del.self__c);      
              system.debug('sitevalue' +del.site);
             
              del.site='';
              newsite.add(del);
              system.debug('sitevalue'+del.site);
            }
           
            Update newsite; 
           
             System.debug('newsitesize' + newsite.Size());  
          }

      
        //  else if((trigger.isInsert || trigger.isUpdate) && c.RecordTypeId==Vendorlocations.Id)
           
                 
              if (trigger.isInsert || trigger.isUpdate)
               {
                                 
                  for(account c : trigger.new)
                 
                    {
             
                    if(c.RecordTypeId==Vendorlocations.Id)
             
                    {
                    locationId.add(c.self__c);
                   }
         
           }
           
        
    }     
           if (trigger.isInsert || trigger.isUpdate)
               {
                                 
                  for(account z : trigger.new)
                 
                    {
             
                    if(z.RecordTypeId==FiledRead.Id)
             
                    {
                    filedrecord.add(Z.Id);
                   }
         
           }
           
        
    }     


 /*totalRecords.addAll(locationId);
 totalRecords.addAll(filedrecord);
 System.debug('totalsize'+totalRecords.size()); */
system.debug('testingsize'+   locationId.Size()); 
system.debug('FIlereadonlysize'+   filedrecord.Size());      
 Map<Id,String> Sitecodevalue = new Map<Id,String>();
 /*for(account d :trigger.new)
 {
if((trigger.isInsert || trigger.isUpdate) && d.RecordType.Name=='filedreadonly')
  {

   filedrecord.add(d.Id);
  }

else
{ */

//List<account> frecords= [Select Id,Site from  account Where RecordType.Name='filedreadonly'];

for(account i: [Select Id,Site from  account Where RecordType.Name='filedreadonly'])
{
  Sitecodevalue.put(i.Id,i.Site);
}




 System.debug('Map Size' +Sitecodevalue.Size());
 
List< account> location = new List <account>();

for(account p : [Select self__c,Site from account Where RecordType.Name='testing' ])
{
String SitevalueAssign = Sitecodevalue.get(p.self__c);

System.debug('ID'+p.Id);

System.debug('value'+SitevalueAssign);
 
 p.Site = SitevalueAssign;
 location.add(p);
 
}
Update location;

System.debug('listsize' + location.Size());


}

}
kumar palepukumar palepu
kindly help me on this why account site value is not saving when i create anew record in account recordtype='testing'.