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
AnicheAniche 

Trigger question

Hi,
 
I have a trigger which works is working fine from the UI.
I am trying to trigger the trigger thorough the dataloader and it doesnt work.
 
Can help me with this. ?
Thanks
 
TehNrdTehNrd
Your trigger is not written in bulk. Check out the apex documentation about bulk triggers or post your code.
AnicheAniche
Code:
trigger AccountT on Account (before update) {


private Account[] oldval = Trigger.old;
private Account[] newval = Trigger.new;

 if (oldval[0].Parentid != null)
   {
   if( oldval[0].ownerid != newval[0].ownerid || oldval[0].Parentid != newval[0].Parentid)       
  {
  string Groupid = oldval[0].parentid;
  newval[0].parentid = null;
 
  Integer Count = [Select count() from Account a where a.Parentid = :Groupid];
 
   if (count < 3)
   {
   Account[] delrec = [ Select b.Id from Account b where b.id = '0017000000NNNOSAA5']; 
   delete delrec[0];
   }
   else
   {
   System.debug('Group is good');
   }
  } 
 }
 else
 {
  System.debug('Not part of group');
 }
}

 

This is the simple thing that i was doing.. I am not familiar with bulk processing.

Can someone help me with this.

Thanks 


 
AnicheAniche
Used Map to process in Bulk.