0

Please find my below code where Redirecting to Detail Page is not working based on boolean value. Can someone please let me know the root cause?

Apex Controller:

public class CallReplica_controller {
public CallReplica_controller() {}
public String Ids {
    get;
    set;
}
public String CallId {
    get;
    set;
}
public List < Call2_vod__c > CList {
    get;
    set;
}
public List < Call2_vod__c > Accts {
    get;
    set;
}
Public Set < Id > Acc {
    get;
    set;
}
Public Set < Boolean > Bool {
    get;
    set;
}
Public Boolean SameSize {
    get;
    set;
}
Public Id leadId {
    get;
    set;
}

public CallReplica_controller(ApexPages.StandardController controller) /*Constructor*/ {
    SameSize = false;
    String id = ApexPages.currentPage().getParameters().get('id');
    CList = [SELECT Account_vod__c, Account_vod__r.Name, Account_Plan_vod__c, Activity_Type__c, Add_Detail_vod__c, Address_vod__c, Address_Line_1_vod__c, Address_Line_2_vod__c, Attendee_Associated_Prescriber_CIA__c, Assignment_Datetime_vod__c, Associated_Prescriber_CIA__c, Allowed_Products_vod__c, Attendee_Associated_Prescriber_ABS_CIA__c, Associated_Prescriber_ABS_CIA__c, Attendee_Post_Status_vod__c, Attendee_Role_CIA__c, Attendee_Type_vod__c, Attendees_vod__c, Breakthrough_Activity_MHC__c, CIA_Switched_Calls_CIA__c, Business_Account_Name_ABT__c, CLM_vod__c, Number_of_CRNA_abt__c, zvod_Call_Conflict_Status_vod__c, Owner_Full_Name_abv__c, Call_Role_Header_CIA__c, City_vod__c, Color_vod__c, Credentials_vod__c, CreatedDate, CreatedById, Contract_Next_Steps_MHC__c, Contact_vod__c, Call_Date_vod__c, Call_Datetime_vod__c, IsDeleted, Deliver_Any_Day_abv__c, Delivery_Day_abt__c, Delivery_Day_2_abt__c, Delivery_Day_3_abt__c, Delivery_Day_4_abt__c, Disbursed_To_vod__c, Detailed_Products_vod__c, Duration_vod__c, Disclaimer_vod__c, Entity_Display_Name_vod__c, Entity_Reference_Id_vod__c, Error_Reference_Call_vod__c, Expense_Amount_vod__c, Expense_Attendee_Type_vod__c, Expense_Post_Status_vod__c, Expense_System_External_ID_vod__c, Getting_Started_Kits_ABT__c, Formatted_Name__c, Attendee_Affirmation_CIA__c, Affirmation_CIA__c, Incurred_Expense_vod__c, IsLocked, Is_Parent_Call_vod__c, Is_Sampled_Call_vod__c, Interaction_abt__c, License_Status_ABT__c, License_Expiration_Date_vod__c, License_Expiration_Date_ABT__c, License_ABT__c, Location_Services_Status_vod__c, zvod_Business_Account_vod__c, MAX_ID_ABT__c, Number_of_MD_abt__c, MD_Time_abt__c, Medical_Event_vod__c, MayEdit, Next_Steps_Overall_abv__c, Next_Step_Overall_MHC__c, Modified_Call_Reference_HS__c, Mobile_Last_Modified_Datetime_vod__c, OwnerId, Override_Lock_vod__c, Attendee_list_vod__c, Parent_Address_vod__c, Parent_Call_vod__c, Parent_Call_Mobile_ID_vod__c, Number_of_Pharmacy_abt__c, Submit_DateTime_ABT__c, X24_X_7_nurse_phone_support_ABT__c, ASSMCA_vod__c, Add_Key_Message_vod__c, Assigner_vod__c, CRNA_Time_abt__c, Call_Sample_Update__c, Call_Comments_vod__c, Concur_Address_abv__c, Concur_Description_abv__c, DEA_vod__c, DEA_Address_vod__c, DEA_Address_Line_1_vod__c, DEA_Address_Line_2_vod__c, DEA_City_vod__c, DEA_Expiration_Date_vod__c, DEA_State_vod__c, DEA_Zip_vod__c, DEA_Zip_4_vod__c, HPP_DMARD_Benefit_ABT__c, HPP_copay_support_ABT__c, HPP_foundation_support_ABT__c, Insurance_process_support_ABT__c, LastActivityDate, Last_Device_vod__c, Last_Modified_By__c, LastModifiedById, LastModifiedDate, License_vod__c, License_Status_vod__c, Location_vod__c, Medication_reminders_ABT__c, Mobile_Created_Datetime_vod__c, Mobile_ID_vod__c, Next_Call_Notes_vod__c, No_Disbursement_vod__c, Name, Nurse_injection_training_ABT__c, Original_Call_Reference_HS__c, Number_of_Other_HCPs_abt__c, Other_HCP_Time_abt__c, Pharmacy_Time_abt__c, Planning_Time_abt__c, Pre_Call_Notes_vod__c, Presentations_vod__c, Product_Priority_1_vod__c, Product_Priority_2_vod__c, Product_Priority_3_vod__c, Product_Priority_4_vod__c, Product_Priority_5_vod__c, Professional_Abbott_Best_Specialty_ABT__c, Professional_Degree_ABT__c, Professional_First_Name_ABT__c, Professional_Last_Name_ABT__c, Professional_ME_ABT__c, Professional_Middle_Name_ABT__c, Professional_Salutation_ABT__c, Professional_Status_ABT__c, Professional_Type_ABT__c, Property_vod__c, Number_of_RN_cia__c, RN_Time_cia__c, Id, RecordTypeId, Salesforce_ABT__c, Salutation_vod__c, Sample_Card_vod__c, Sample_Card_Reason_vod__c, Sample_Send_Card_vod__c, Sharps_containers_ABT__c, Sharps_mailback_services_ABT__c, Ship_Address_Line_1_vod__c, Ship_Address_Line_2_vod__c, Ship_City_vod__c, Ship_Country_vod__c, Ship_License_vod__c, Ship_License_Expiration_Date_vod__c, Ship_License_Status_vod__c, Ship_State_vod__c, Ship_To_Address_Text_vod__c, Ship_To_Address_vod__c, Ship_Zip_vod__c, Ship_Zip_4_vod__c, Signature_vod__c, Signature_Date_vod__c, Signature_Location_Latitude_vod__c, Signature_Location_Longitude_vod__c, Signature_Page_Image_vod__c, Signature_Timestamp_vod__c, Significant_Event__c, Site_Onboarding_Next_Steps_abv__c, State_vod__c, Status_vod__c, Subject_vod__c, Submitted_By_Mobile_vod__c, Supervising_Physician_vod__c, Supervising_Physician_Credential_vod__c, Supervising_Physician_License_vod__c, Supervising_Physician_Name_vod__c, SystemModstamp, Territory_vod__c, Total_Expense_Attendees_Count_vod__c, Travel_Time_abt__c, Call_Type_vod__c, USHCP_abv__c, Uncovering_Needs_abt__c, Unlock_vod__c, User_vod__c, Zip_vod__c, Zip_4_vod__c, myHUMIRA_Overview_ABT__c FROM Call2_vod__c where id = : id];
    Acc = new Set < Id > ();
    System.debug('My call-->' + CList);
    if (CList.get(0).Parent_call_vod__c != null) {
        Accts = [select Account_vod__c, Id from Call2_vod__c where Parent_call_vod__c = : CList.get(0).Parent_call_vod__c];
        For(Call2_vod__c c: Accts) {
            Acc.add(c.Account_vod__c);
        }
        Acc.add(CList.get(0).Account_vod__c);
    }
    List < UserRecordAccess > HasAccessList = [SELECT RecordId, HasReadAccess FROM UserRecordAccess WHERE UserId = : UserInfo.getUserId() AND RecordId IN: Acc LIMIT 200];
    For(UserRecordAccess URA: HasAccessList) {
        SameSize = URA.HasReadAccess;
        If(SameSize)
        break;
    }
    System.debug('@SameSize@' + SameSize);
}
public PageReference getredirectPage() {
    if (SameSize) {
        leadId = CList.get(0).Parent_call_vod__c;
        System.debug('SameSize@' + SameSize);
        PageReference send = new PageReference('/' + leadId);
        send.setRedirect(true);
        return send;

    } else return null;
}
}
0

Your HasAccessList.size() == Acc.size() is not triggering. Revisit your query and logic.

By the looks of it, you're comparing if the size of the two objects are the same, I'm not sure if that's what you intended.

Also, clean up your code before posting it'll help us help you better.

| improve this answer | |
  • How can I trigger redirectpage from my VF page? Do I need a flow? – Testing_SFDC Jul 22 '15 at 17:22
  • No you don't. You just have to return a new pagereference like so: return new PageReference('/apex/visualforcepagename?id='+myObject.ID); By the looks of your code, it seems liek that should work. Recheck your SameSize boolean logic. Place some debug codees if the .size()s are the same. – dotmiko Jul 22 '15 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.