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
Krzysztof KotKrzysztof Kot 

Opening the subTab with the field update by the Apex method via visualforce page

Hey, I have a list of records displayed (in my case a list of surveys). I want when the user clicks on the link (it can be a button) the system opens the survey record as subTab with the simultaneous update of one field (reading flags). Unfortunately, I can not pin this down and the value of the parameter (surveyId) is not passed to the Apex class method.

visualforce page:
<apex:page standardcontroller="Case" standardStylesheets="false" lightningStylesheets="true" docType="html-5.0" extensions="SurveyController">
<apex:slds />
<style type="text/css">
.y{background-color: #ffff99}
.g{background-color: #99ff99}
</style>
<apex:includeScript value="/support/console/44.0/integration.js" />
<apex:includeScript value="/support/api/44.0/interaction.js" />
<script language="javascript" type="text/javascript">
function openRecordPage(){
    saveSurveyId('ss');
    chageSurveyFlag();
}
</script>
<apex:form id="form2">       
   <apex:pageBlock id="pageblock" >
            <apex:actionFunction action="{!chageSurveyFlag}" name="chageSurveyFlag">
            <apex:param id="myParam" name="myParam" value="hoho" assignTo="{!surveyId}"/>
            </apex:actionFunction>
            <apex:pageblocktable value="{!surveyTaker}" var="survey" id="blocktable">
              <apex:column value="{!survey.CreatedDate}" headerValue="Data" styleClass="{!if(survey.IsRead__c,"g","y")}"/>
              <apex:column value="{!survey.Survey__c}" headerValue="Nazwa ankiety" styleClass="{!if(survey.IsRead__c,"g","y")}"/>
              <apex:column styleClass="{!if(survey.IsRead__c,"g","y")}" id="column">
              <apex:inputHidden value="{!survey.Id}" id="hiddenField"/>
              <apex:outputLink value="/{!survey.Id}" onclick="openRecordPage(); return false;">Szczegóły
              </apex:outputLink>
              </apex:column>
            </apex:pageblocktable>
  </apex:pageBlock>
   </apex:form>
</apex:page>

apex class controller:
public with sharing class SurveyController {
    private final Case c;
    private ApexPages.StandardController controller {get; set;}
    public List<SurveyTaker__c> surveysForCase {get; private set;}
    public List<SurveyTaker__c> surveyTaker  {get; private set;}
    public String caseId {get; set;}
    public String surveyId {get; set;}
        
	public SurveyController(ApexPages.StandardController controller) {
        this.controller = controller;
        this.c = (Case) controller.getRecord();
        searchSurveyTaker();
    }
    public void searchSurveyTaker () {
		surveyTaker = [Select Survey__c, Case__c, CreatedDate, IsRead__c, Id FROM SurveyTaker__c WHERE Case__c =: c.Id ORDER BY CreatedDate DESC]; 
    }
    public PageReference chageSurveyFlag() {
        System.debug('survey: '+surveyId);
        SurveyTaker__c s = new SurveyTaker__c();
        s.id = surveyId;
        s.isRead__c = true;
        update s;
        return null;
    }
    
}