I have created a list view button that calls Visualforce page with controller that creates some records based on multiple Selection of records at the list view , after that I want to redirect to a new window that opens an external URL, it works fine but we have a requirement to redirect the Initial VF page back to List view after external URL loads. Tried various methods but couldn't make the initial VF page to redirect back to List view. Is this even possible? How do i make the visual force page reload it back to List view page after the window.Open finish?

public with sharing class ListViewControllerEVS {

public List <Patient_Rounding__c> LstSelectedPE {get;set;}
public Boolean initialised{get; set;}

public ListViewControllerEVS(ApexPages.StandardSetController listcontroller) {
    Set <Id> PESelectedIds = new set <Id> ();
    LstSelectedPE = new List <Patient_Rounding__c>();
    for (Patient_Rounding__c c: (Patient_Rounding__c[]) listcontroller.getSelected()){
    /**Querying on the Selected records and fetching fields which are required in Flow **/
    LstSelectedPE = [select Id, Patient_Care_Location__c, Patient_Care_Location__r.rkl__Location_2_Node__r.Id from Patient_Rounding__c where id in: PESelectedIds];
    system.debug(logginglevel.debug, 'DEBUG: SelectedList:    '  + LstSelectedPE);
public pagereference Init(){
    system.debug(logginglevel.debug, 'DEBUG: Init is:    '  + initialised);
    List<rkqf__Questionnaire_Template__c> TemplateEVS =[Select ID, Template_Type1__c from rkqf__Questionnaire_Template__c where rkqf__is_Published__c= TRUE AND Template_Type1__c ='Inpatient EVS Leader' Order By LastModifiedDate Desc Limit 1];
    If (TemplateEVS!=NULL){
        if (initialised){
            Date DueDate = System.today()+2;
            List<rkqf__Questionnaire_Assignments__c> NewObjs=new List<rkqf__Questionnaire_Assignments__c>();
            Id Uid=UserInfo.getUserId();
            //List<User> userList = [select contactid from user where id =:UserInfo.getUserId()];
            //List<Contact> acr =[select Id from Contact where Id =:userList[0].ContactId Limit 1];
            for (Patient_Rounding__c c:LstSelectedPE){
                rkqf__Questionnaire_Assignments__c Obj2=new rkqf__Questionnaire_Assignments__c();
                Obj2.rkqf__Status__c= 'Not Started';
                Obj2.Name='Inpatient EVS Leader Patient Rounding';
                Obj2.rkqf__Assigned_To_User__c= UserInfo.getUserId();
                Obj2.rkqf__Due_Date__c= DueDate; 
                Obj2.rkqf__Questionnaire_Template__c= TemplateEVS[0].Id;
                Obj2.Template_Type__c= TemplateEVS[0].Template_Type1__c;
                //  Obj2.rkqf__Assigned_To_Contact__c=acr[0].Id;
            Insert NewObjs;
            system.debug(logginglevel.debug, 'DEBUG: Init is:    '  + initialised);
            system.debug(logginglevel.debug, 'DEBUG: Assignments are:    '  + NewObjs);
    return null;

Visual Force Page

<apex:page standardController="Patient_Rounding__c" recordSetVar="Cs" extensions="ListViewControllerEVS"  lightningStylesheets="True" >


    window.open('External URL');




Your Answer

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

Browse other questions tagged or ask your own question.