• Jay Gatsby
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
I have this requirement in my project, its called post refresh activity. We have refreshed our sandbox from production. Now we have 30+ master rescords to be inserted into sandbox, we can do it manually via, Dataloader/online Dataloader.io but its time consuming.

Now I want to make it automatic, like reading these csv files in apex class and insert data/records to respective objects. I have just overview of this, but i am not sure from where do i start.

It will be helpful if anyone can guide me little bit.

Thanks 
I have below sample method

@testVisible
    private static Map<String,Object> getSampleMap(List<Object> sampleList){
        Map<String,Object> sampleMap = new Map<String,Object>();
        if(sampleList!= null && sampleList.size()>0 ){
            for(Object obj : sampleList){
                sampleMap.put(obj.field1,obj);
            }
        }
        return sampleMap ;
    }
User-added image
Two custom objects:
1.Building__c
2.Unit__c and Master-detail with Building__c

i wrote trigger on my unit object


/*trigger addUnitTrigger on Unit__c (after insert, after update) {
    
    List<Building__c>   building = [select id from Building__c];
    List<Id> id= new List<Id>();
    
    for(Building__c b: building){
        
        id.add(b.id);
    }
    
    List<Unit__c>  unit  = [select Add_Units__c, id,Building__c from Unit__c where Unit__c.Building__r.id IN :id];
    Building__c b;
    integer sum=0;
    for(Unit__c u: unit){
        sum= sum + Integer.valueOf(u.Add_Units__c);
        b =  [select id,Number_of_Units__c from Building__c where Id =: u.Building__c];
        b.Number_of_Units__c= sum;
    }
    
    upsert b;
    
}*/
I am not getting the error.