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
sk kumarsk kumar 

when ever a jobaplicant record iss created or updated then update the corresponding bill rate as 1000...below my trigger code given:-

trigger recursive on job_aplicationn__c (after insert,after update)
{
if(trigger.isinsert)
{
list<job_aplicationn__c >jobapplist=new list<job_aplicationn__c >();
   {
for(job_aplicationn__c ja:trigger.new)
   {
  jobapplist.add(ja);
   }
recursive trigger.method(jobapplist);
{
if(trigger.isinsert)
{
list<job_aplicationn__c >jobapplist=new list<job_aplicationn__c >
   {
for(job_aplicationn__c ja:trigger.new)
   {
  jobapplist.add(ja);
   }
recursive trigger.method(jobapplist);
  {
  if(trigger.isupdate)
  {
  list<job_aplicationn__c >jobapplist=new list<job_aplicationn__c >
  {
   for(job_aplicationn__c ja.trigger.new)
   {
    job_aplicationn__c jobappold=trigger.oldmap.get(ja.id);
    job_aplicationn__c jobappnew=trigger.newmap.get(ja.id);
    double billratenew=jobappold.bil_rate__c;
    double billrateold=jobappnew.bil_rate__c;
    if(billratenew!=billrateold)
    {
   jobapplist.add(ja);
    }
   }
   recursive trigger.method(jobapplist);
   }
   public class recursive trigger
   {
    public static void method(list<job_aplicationn__c >jobapplist){
    set<id>ids=new set<id>();
    for(job_aplicationn__c ja:jobapplist)
      {
     ids.add(ja.id);
       }
   list<job_aplicationn__c >jalist=[select id,bil_rate__c from job_aplicationn__c where id in:ids ];
   for(job_aplicationn__c j:jalist)
   {
   j.bil_rate__c =100;
   }
   update jalist;
   }
  }
  );
  {
  if(trigger.isupdate)
  {
  list<job_aplicationn__c >jobapplist=new list<job_aplicationn__c >();
  {
   for(job_aplicationn__c ja.trigger.new)
   {
    job_aplicationn__c jobappold=trigger.oldmap.get(ja.id);
    job_aplicationn__c jobappnew=trigger.newmap.get(ja.id);
    double billratenew=jobappold.bil_rate__c;
    double billrateold=jobappnew.bil_rate__c;
    if(billratenew!=billrateold)
    {
   jobapplist.add(ja);
    }
   }
   recursive trigger.method(jobapplist);
   }
   public class recursive trigger
   {
    public static void method(list<job_aplicationn__c >jobapplist)
    {
    set<id>ids=new set<id>();
    for(job_aplicationn__c ja:jobapplist)
      {
     ids.add(ja.id);
       }
   list<job_aplicationn__c >jalist=[select id,bil_rate__c from job_aplicationn__c where id in:ids ];
   for(job_aplicationn__c j:jalist)
   {
   j.bil_rate__c =100;
   }
   update jalist;
   }
  }


m getting an error called ==   Error Error: Compile Error: Illegal variable declaration: trigger.method at line 11 column 12



anyone plz help me out..!!!!
Sonam_SFDCSonam_SFDC
I understand you are calling the function method in class: recursive trigger - were you able to save this class?

the class name cannot have space: http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_classes.htm

Please save the class first after updating the name and then try execute the trigger..




Chidambar ReddyChidambar Reddy
Hi Kumar,

This error is due to the class name 'recurcive trigger'

You can rename that and make changes in trigger as well,


But this trigger will not work properly.
It will give an error that 'Record is read only after update caused an exception ' like that.
As you cannot update the records on after update trigger.

Try using before triggers as you want to update the field of same object.


If you want to process the requirement


Write the trigger as below or you can even use a simple work flow rule

trigger recursive on job_aplicationn__c (before insert, before update)
{
       for(job_aplicationn__c ja:trigger.new){
           ja.bil_rate__c =100; 
       }
}
   

The above trigger is enough for your requirement.


Thank you
Choose it as best answer if it resolved your issue.