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
suji srinivasansuji srinivasan 

how to use old values /prior values condition in invocable apex?

if picklist record_status__c is changed from 'inprogress' to 'active ' in new salary record 

I want to update record_status__c as inactive in old salary record

public class Update_salary_Recordstatus_as_Inactive {
    @InvocableMethod(label='Update salary  Recordstatus as Inactive' description='Returns the list of salary active records' )
    Public static List<Salary_Detail__c> getsalary(){
  
    Set<String> EmployeeId = new Set<String>();
    Id auRecordTypeId = Schema.SObjectType.Salary_Detail__c.getRecordTypeInfosByName().get('Compensation').getRecordTypeId();
    for(Employee_Information__c e :[select id,Employee_Id__c from Employee_Information__c where Tax_Regime__c!=null AND Employee_Id__c != Null ] ){
            EmployeeId.add(e.Employee_Id__c);}
    List<Salary_Detail__c>sallist =[select id,Employee_First_Name__c,Employee_Last_Name__c,Employee_Information__c,RecordTypeId,Employee_ID__c,Confirmed_CTC__c,Record_Status__c from Salary_Detail__c WHERE RecordTypeId=:auRecordTypeId AND Employee_Id__c IN :EmployeeId];
    List<Salary_Detail__c>Inactivesallist = new  List<Salary_Detail__c> ();
   
   
    for (Salary_Detail__c s :sallist){
          s.Record_Status__c ='Inactive'; 
          //s.oldRecordstatus= trigger.oldmap.get
          Inactivesallist.add(s);
    }
   
  return Inactivesallist;                                
} }

how to mention oldvalue is inprogress in this apex class?

Thanks in advance