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
moffetmoffet 

trigger on related object field

hi,

  i need to write trigger on position object

  the position object contains check box (Travel Required)

  and  Job Application object contains status field

  when i checked the Travel Required check box the trigger should be fired so that status field in Job Application should be changed to Rejected

         there is a lookup relation between those two objects

           whenever the checkbox of one position is checked the related Job Applications status field muct be changed to "Rejected"

 

 

               can anyone help me pls

Best Answer chosen by Admin (Salesforce Developers) 
asish1989asish1989

Hi

   Try this...

           

            

trigger UpdateStatusInJobApplication on Position__c (after update){
     List<Job_Application__c> jobApp = new List<Job_Application__c>();
      if(Trigger.new[0].Travel_Required__c != NULL){

             jobApp = [select Id , Name ,position__c,Status__c from Job_Application__c where position__c =:Trigger.new[0].Id];
            for(Job_Application__c job :jobApp){
                     if(Trigger.new[0].Travel_Required__c == true){
                            job.Status__c ='Rejected' ;

                            jobApp.add(job);


                      }
                 
           }
              update jobApp ;

       }
}

 

Did this post solve your problem If so please mark it solved otherwise let me know about your Issue

 

Thanks

asish

All Answers

moffetmoffet

i already done recruiting app i am working on triggers

asish1989asish1989

Hi

   Try this...

           

            

trigger UpdateStatusInJobApplication on Position__c (after update){
     List<Job_Application__c> jobApp = new List<Job_Application__c>();
      if(Trigger.new[0].Travel_Required__c != NULL){

             jobApp = [select Id , Name ,position__c,Status__c from Job_Application__c where position__c =:Trigger.new[0].Id];
            for(Job_Application__c job :jobApp){
                     if(Trigger.new[0].Travel_Required__c == true){
                            job.Status__c ='Rejected' ;

                            jobApp.add(job);


                      }
                 
           }
              update jobApp ;

       }
}

 

Did this post solve your problem If so please mark it solved otherwise let me know about your Issue

 

Thanks

asish

This was selected as the best answer
moffetmoffet

its working

 

                 thank you