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
Ganta SureshGanta Suresh 

What is this below can is doing. Can anyone please explain me and I need to convert this class in flow? do this need full

public class AksChecklist 
{
   // public Eagle_Arrangement__c agr{get;set;}
    public Internal_Risk_Rating_Detail__c irr{get;set;}
    public AKS_Checklist_AGR__c aksrec{set;get;}
    public integer i=0;
   // public Id agreementid{get;set;}
    public Id internalid{get;set;}
    
    Id recordTypeId = [Select Id,Name from RecordType where Name='Consulting Arrangement' and SOBjectType='Eagle_Arrangement__c'].Id;
   // public id recordtype{set;get;}
    public AksChecklist(apexpages.StandardController cont)
        
    {
      aksrec=(AKS_Checklist_AGR__c)cont.getRecord();
        system.debug('aksid'+aksrec);
        internalid=ApexPages.currentPage().getParameters().get('irrid');
        if(aksrec!=null && aksrec.id!=null){
           
            aksrec=[select id,name,Createddate__c ,LastModifiedDate__c,LastModifiedBy.name,CreatedBy.name,Internal_Risk_Details__c,Internal_Risk_Details__r.Arrangement__c,Internal_Risk_Details__r.Arrangement__r.recordtype.name,Respond_to_Question_1__c,Internal_Risk_Details__r.Arrangement__r.Agreement_Sub_Type__c ,
                    Respond_to_Question_2__c,Respond_to_Question_3__c,Respond_to_Question_4__c,Respond_to_Question_5__c,Respond_to_Question_6__c,Respond_to_Question_7__c,Respond_to_Question_8__c,Respond_to_Question_9__c,Respond_to_Question_10__c,Respond_to_Question_11__c from AKS_Checklist_AGR__c where id=:aksrec.id]; 
            internalid=aksrec.Internal_Risk_Details__c;
        }
        irr=[select id,name,legal_AKS_confirmation__c,Arrangement__c,Arrangement__r.name,Arrangement__r.Agreement_Sub_Type__c,Arrangement__r.Recordtype.name,Arrangement__r.ROD__c,Arrangement__r.DVP__c,Arrangement__r.Status__c,Arrangement__r.Next_Approver__c from Internal_Risk_Rating_Detail__c where id=:internalid];
       // system.debug(irr.Arrangement__r.Recordtype.name);
         
      // this.agreementid=ApexPages.currentPage().getParameters().get('agrid');
          // agr=[Select Id,ROD__c,DVP__c ,Status__c, Next_Approver__c,recordtype.name from Eagle_Arrangement__c where id=:agreementid];
  
    }
    public pagereference divert(){
        PageReference pr=new PageReference('/apex/akschecklistredirection');//other developer page url here
       if(irr.Arrangement__r.recordtype.name=='RS Lease' || irr.Arrangement__r.recordtype.name=='Settlement' || irr.Arrangement__r.recordtype.name=='other'|| irr.Arrangement__r.recordtype.name=='Consulting Arrangement' || irr.Arrangement__r.recordtype.name=='Hospital Services Arrangement' || irr.Arrangement__r.recordtype.name=='SNF HHD Coordination Agreement' || irr.Arrangement__r.recordtype.name=='MDA' || irr.Arrangement__r.recordtype.name=='Sublease Remediation' || irr.Arrangement__r.recordtype.name=='Patient Pathways' ){//add othe record types here 
            pr=null;
        }
        return pr;
    }
    public pagereference divert1(){
        PageReference pr=new PageReference('/apex/akschecklistredirectionview');//other developer page url here
       if(irr.Arrangement__r.recordtype.name=='RS Lease' || irr.Arrangement__r.recordtype.name=='Settlement' || irr.Arrangement__r.recordtype.name=='other'|| irr.Arrangement__r.recordtype.name=='Consulting Arrangement' || irr.Arrangement__r.recordtype.name=='Hospital Services Arrangement' || irr.Arrangement__r.recordtype.name=='SNF HHD Coordination Agreement' || irr.Arrangement__r.recordtype.name=='MDA' || irr.Arrangement__r.recordtype.name=='Sublease Remediation' || irr.Arrangement__r.recordtype.name=='Patient Pathways'){//add othe record types here 
           pr=null;
        }
        return pr;
    }
     public pagereference divert2(){
        PageReference pr=new PageReference('/apex/akschecklistredirectionedit');//other developer page url here
       if(irr.Arrangement__r.recordtype.name=='RS Lease' || irr.Arrangement__r.recordtype.name=='Settlement' || irr.Arrangement__r.recordtype.name=='other'|| irr.Arrangement__r.recordtype.name=='Consulting Arrangement' || irr.Arrangement__r.recordtype.name=='Hospital Services Arrangement' || irr.Arrangement__r.recordtype.name=='SNF HHD Coordination Agreement' || irr.Arrangement__r.recordtype.name=='MDA' || irr.Arrangement__r.recordtype.name=='Sublease Remediation' || irr.Arrangement__r.recordtype.name=='Patient Pathways'){//add othe record types here 
            pr=null;
        }
        return pr;
    }
   /* public pagereference akspagego()
    {
      PageReference pr=new PageReference('/apex/AksChecklist');
          pr.getParameters().put('varArrangementId',agr.Id);
              pr.getParameters().put('varRecordType',recordTypeId);
              
        pr.getParameters().put('irrid',aksrec.id);
        pr.getParameters().put('retURL',agr.id);
            return pr ;
    }*/
    
        
   
    
    public pagereference save(){
        aksrec.Internal_Risk_Details__c=irr.id;
        if(aksrec.id!=null){
         
                update aksrec;
            //list<AKS_Checklist_AGR__c> akss=[select id,name,Internal_Risk_Details__c,Respond_to_Question_1__c,Respond_to_Question_2__c,Respond_to_Question_3__c,Respond_to_Question_4__c,Respond_to_Question_5__c,Respond_to_Question_6__c,Respond_to_Question_7__c,Respond_to_Question_8__c,Respond_to_Question_9__c,Respond_to_Question_10__c,Respond_to_Question_11__c from AKS_Checklist_AGR__c where Internal_Risk_Details__c=:irr.id];
            //for(AKS_Checklist_AGR__c aksrec1:akss){
            if((aksrec.Respond_to_Question_1__c=='Yes' && aksrec.Respond_to_Question_2__c=='Yes' && aksrec.Respond_to_Question_3__c=='Yes' && aksrec.Respond_to_Question_4__c=='Yes'  && aksrec.Respond_to_Question_5__c=='Yes' && aksrec.Respond_to_Question_6__c=='Yes' && aksrec.Respond_to_Question_7__c=='Yes'  && aksrec.Respond_to_Question_8__c=='Yes'  && aksrec.Respond_to_Question_9__c=='Yes') || (aksrec.Respond_to_Question_10__c=='Yes'  && aksrec.Respond_to_Question_11__c=='Yes'))
            {
                //i++;
                //}
            //}if(akss.size()==i){
            irr.legal_AKS_confirmation__c='Complete';
                  }
            else{
                    irr.legal_AKS_confirmation__c='Not All Affirmative';   
                  }
            update irr;
        }else{
           
            insert aksrec;
 //list<AKS_Checklist_AGR__c> akss=[select id,name,Internal_Risk_Details__c,Respond_to_Question_1__c,Respond_to_Question_2__c,Respond_to_Question_3__c,Respond_to_Question_4__c,Respond_to_Question_5__c,Respond_to_Question_6__c,Respond_to_Question_7__c,Respond_to_Question_8__c,Respond_to_Question_9__c,Respond_to_Question_10__c,Respond_to_Question_11__c from AKS_Checklist_AGR__c where Internal_Risk_Details__c=:irr.id];
            //for(AKS_Checklist_AGR__c aksrec1:akss){
            if((aksrec.Respond_to_Question_1__c=='Yes' && aksrec.Respond_to_Question_2__c=='Yes' && aksrec.Respond_to_Question_3__c=='Yes' && aksrec.Respond_to_Question_4__c=='Yes'  && aksrec.Respond_to_Question_5__c=='Yes' && aksrec.Respond_to_Question_6__c=='Yes' && aksrec.Respond_to_Question_7__c=='Yes'  && aksrec.Respond_to_Question_8__c=='Yes'  && aksrec.Respond_to_Question_9__c=='Yes') || (aksrec.Respond_to_Question_10__c=='Yes'  && aksrec.Respond_to_Question_11__c=='Yes'))
            {
               // i++;
                //}
            //}if(akss.size()==i){
            irr.legal_AKS_confirmation__c='Complete';
                  }
            else{
                    irr.legal_AKS_confirmation__c='Not All Affirmative';   
                  }
            update irr;       
        }
        PageReference pr =new PageReference('/'+irr.id);
       // PageReference pr =new PageReference('/apex/AKSChecklistview?id=aksrec.id');
        
        return pr;
    }

   /* public pagereference aksflow()
    {
      PageReference pr=new PageReference('/flow/AKSChecklist_flow');
          pr.getParameters().put('varArrangementId',agr.Id);
              pr.getParameters().put('varRecordType',recordTypeId);
              
        pr.getParameters().put('irrid',irr.id);
        pr.getParameters().put('retURL',agr.id);
            return pr ;
    }*/
    
    public pagereference closepage()
    {
        pagereference pr1=new pagereference('/'+irr.id);
        return pr1;
    }
     
}
Prateek Prasoon 25Prateek Prasoon 25
Answer :-

This is an Apex class in Salesforce which contains variables and methods to handle a custom object named AKS_Checklist_AGR__c. The object has fields like Respond_to_Question_1__c, Respond_to_Question_2__c, etc. which are being used in the code.
Let's go through the code step by step:
The class name is AksChecklist.
The class has four variables: irr, aksrec, i, and internalid.
irr is an object of type Internal_Risk_Rating_Detail__c, a custom object in Salesforce.
aksrec is an object of type AKS_Checklist_AGR__c, also a custom object in Salesforce.
i is an integer variable, which is initialized to 0.
internalid is an Id variable.
The class has a constructor method, which takes an instance of apexpages.StandardController as a parameter. Inside the constructor, the following steps are performed:
The aksrec variable is initialized with the record retrieved using the getRecord() method of the StandardController instance.
The internalid variable is initialized with the value of the "irrid" parameter in the current page URL.
If the aksrec variable is not null and has a non-null ID, then it is queried again to retrieve additional fields.
The irr variable is initialized with the record retrieved using the internalid variable.

The class has three methods: divert(), divert1(), and divert2(). All these methods return a PageReference object, which can be used to redirect the user to a different page. The methods perform the following steps:
Create a new PageReference object for the target page.
Check the record type of the "Arrangement__c" field of the irr variable. If it matches one of the specified record types, then set the PageReference object to null.
Return the PageReference object.

As for converting this class to Flow, it would require significant changes to the code as Flow and Apex are different programming languages. It is not possible to provide a full conversion without additional information about the business logic and requirements. It would be best to understand the current functionality and reimplement it using Flow's tools and features.

If you find my answer helpful, please mark it as the best answer. Thanks