+ Start a Discussion
SwaranPoladiSwaranPoladi 

Trigger Record

Hi,

 

I have a scenario.

 

We have batch load that inserts number of records on to custom object. For all these records created in a batch we have to create one parent record e.g:- if a CSV file has 10000 records then 1 record to inserted and tag all 10000 records with it.

 

I have tried using static variable but its not working 

 

below is the code

 

trigger Change on Site__c(before insert, before update){ 
Set<Id> setSiteId = new Set<Id>(); 
List<Site__c> ltSiteUpd=new List<Site__c>(); 
if(setStaticVars_CLS.firstrun==1){ 
setStaticVars_CLS.setinsertTariffChange();
setStaticVars_CLS.firstrun++; 

for(Site__c objSR:Trigger.New){
if(Trigger.isInsert){
objSR1.Tariff_Change__c=setStaticVars_CLS.getinsertTariffChange();
ltSiteUpd.add(objSR1);
}

}

Static class

global class setstaticVars_Cls{

global static Integer firstrun=1;
global static Id idTC;
global static void setinsertTariffChange(){
Tariff_Change__c objTC=new Tariff_Change__c();
insert objTC;
idTC=objTC.id;
}
global static Id getinsertTariffChange(){
return idTC;
}
}

SFAdmin5SFAdmin5

i think you will need a batch job to handle that volume of record inserts