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
GYAN ANDRUSGYAN ANDRUS 

Hi Can anyone please help on this,I am opening a reports based on command button,I want to open this report in separate tab /window using command button

Apex page:

<apex:page controller="ReportController" >
    
    <apex:form >
        <apex:pageBlock title="Choose Report" id="out">
            <apex:pageBlockButtons >
                
                
                <apex:actionStatus id="actStatusId">
                    <apex:facet name="start">
                        <img src="/img/loading.gif" />
                    </apex:facet>
                </apex:actionStatus>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Choose Report Names">
                <apex:selectList value="{!selectedReport}" multiselect="false" size="1">
                    <apex:selectOptions value="{!reportsOptions}"/>
                    
                </apex:selectList>
              <apex:commandButton value="Show Reports" action="{!showReports}" reRender="out" status="actStatusId" /> 
                               <apex:commandButton value="Tab" action="{!URLFOR($Action.Account.Tab, $ObjectType.Account)}"/>

                <!--<apex:commandLink target="_blank" styleClass="btn" style="text-decoration:none;padding:4px;" action="{!showReports}" />-->
            </apex:pageBlockSection>
            
            
        </apex:pageBlock>
        <apex:pageBlock >
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

controller:

public with sharing class ReportController {
    
    public PageReference showReports() {
        try{
            Report objReport = [Select Id from Report where name=:selectedReport];
            PageReference report = new PageReference('/'+objReport.Id);
            report.setRedirect(true);
            return report;
        }catch(Exception e){
            return null;
        }
    }
    
    
    public String selectedReport{get;set;}
    public List<String> selectedCategories { get; set; }
    
    public List<SelectOption> getReportsOptions() {
        List<SelectOption> countryOptions = new List<SelectOption>();
        countryOptions.add(new SelectOption('','-None-'));
        countryOptions.add(new SelectOption('No Of Open Contracts','No Of Open Contracts'));
        countryOptions.add(new SelectOption('Number of Contracts','Number of Contracts'));
        System.debug('countryOptions: ' + countryOptions);
        return countryOptions;
    }
    
    
    public List<SelectOption> getCategories() {
    List<SelectOption> categories = new List<SelectOption>();
    System.debug('TCategories: ' + categories);   
    return categories;
        
    }
    
    
}

i tried command link,but its not wrorking in lightening